Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1114744

Browse files
committed
merge
2 parents ab69438 + 58de6ee commit 1114744

4 files changed

Lines changed: 28 additions & 11 deletions

File tree

Doc/c-api/init.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ a worker thread and the actual call than made at the earliest convenience by the
892892
main thread where it has possession of the global interpreter lock and can
893893
perform any Python API calls.
894894

895-
.. cfunction:: void Py_AddPendingCall( int (*func)(void *, void *arg) )
895+
.. cfunction:: void Py_AddPendingCall(int (*func)(void *), void *arg)
896896

897897
.. index:: single: Py_AddPendingCall()
898898

Lib/test/test_startfile.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from test import support
1212
import os
1313
from os import path
14+
from time import sleep
1415

1516
startfile = support.get_attribute(os, 'startfile')
1617

@@ -23,6 +24,10 @@ def test_empty(self):
2324
empty = path.join(path.dirname(__file__), "empty.vbs")
2425
startfile(empty)
2526
startfile(empty, "open")
27+
# Give the child process some time to exit before we finish.
28+
# Otherwise the cleanup code will not be able to delete the cwd,
29+
# because it is still in use.
30+
sleep(0.1)
2631

2732
def test_main():
2833
support.run_unittest(TestCase)

Misc/NEWS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ Core and Builtins
5555
Library
5656
-------
5757

58+
- Issue #11768: The signal handler of the signal module only calls
59+
Py_AddPendingCall() for the first signal to fix a deadlock on reentrant or
60+
parallel calls. PyErr_SetInterrupt() writes also into the wake up file.
61+
5862
- Issue #11467: Fix urlparse behavior when handling urls which contains scheme
5963
specific part only digits. Patch by Santoso Wijaya.
6064

@@ -314,6 +318,8 @@ Build
314318
Tests
315319
-----
316320

321+
- Fix test_startfile to wait for child process to terminate before finishing.
322+
317323
- Issue #11719: Fix message about unexpected test_msilib skip on non-Windows
318324
platforms. Patch by Nadeem Vawda.
319325

Modules/signalmodule.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,20 @@ checksignals_witharg(void * unused)
163163
return PyErr_CheckSignals();
164164
}
165165

166+
static void
167+
trip_signal(int sig_num)
168+
{
169+
Handlers[sig_num].tripped = 1;
170+
if (is_tripped)
171+
return;
172+
/* Set is_tripped after setting .tripped, as it gets
173+
cleared in PyErr_CheckSignals() before .tripped. */
174+
is_tripped = 1;
175+
Py_AddPendingCall(checksignals_witharg, NULL);
176+
if (wakeup_fd != -1)
177+
write(wakeup_fd, "\0", 1);
178+
}
179+
166180
static void
167181
signal_handler(int sig_num)
168182
{
@@ -180,13 +194,7 @@ signal_handler(int sig_num)
180194
if (getpid() == main_pid)
181195
#endif
182196
{
183-
Handlers[sig_num].tripped = 1;
184-
/* Set is_tripped after setting .tripped, as it gets
185-
cleared in PyErr_CheckSignals() before .tripped. */
186-
is_tripped = 1;
187-
Py_AddPendingCall(checksignals_witharg, NULL);
188-
if (wakeup_fd != -1)
189-
write(wakeup_fd, "\0", 1);
197+
trip_signal(sig_num);
190198
}
191199

192200
#ifndef HAVE_SIGACTION
@@ -932,9 +940,7 @@ PyErr_CheckSignals(void)
932940
void
933941
PyErr_SetInterrupt(void)
934942
{
935-
is_tripped = 1;
936-
Handlers[SIGINT].tripped = 1;
937-
Py_AddPendingCall((int (*)(void *))PyErr_CheckSignals, NULL);
943+
trip_signal(SIGINT);
938944
}
939945

940946
void

0 commit comments

Comments
 (0)