From 340bb95ffd9c0947a7f6ac7f4520efada7204bc0 Mon Sep 17 00:00:00 2001 From: Ezio Melotti Date: Mon, 18 Apr 2011 10:11:21 +0300 Subject: #11865: fix typo in init.rst. --- Doc/c-api/init.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst index 6786109..12abf1e 100644 --- a/Doc/c-api/init.rst +++ b/Doc/c-api/init.rst @@ -892,7 +892,7 @@ a worker thread and the actual call than made at the earliest convenience by the main thread where it has possession of the global interpreter lock and can perform any Python API calls. -.. cfunction:: void Py_AddPendingCall( int (*func)(void *, void *arg) ) +.. cfunction:: void Py_AddPendingCall(int (*func)(void *), void *arg) .. index:: single: Py_AddPendingCall() -- cgit v0.12 From 6c9b35bfe2585af08ea6480294e096e2d2397fe3 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 18 Apr 2011 16:25:56 +0200 Subject: Issue #11768: The signal handler of the signal module only calls Py_AddPendingCall() for the first signal to fix a deadlock on reentrant or parallel calls. PyErr_SetInterrupt() writes also into the wake up file. --- Misc/NEWS | 4 ++++ Modules/signalmodule.c | 26 ++++++++++++++++---------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS index c424e1e..022ad20 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -55,6 +55,10 @@ Core and Builtins Library ------- +- Issue #11768: The signal handler of the signal module only calls + Py_AddPendingCall() for the first signal to fix a deadlock on reentrant or + parallel calls. PyErr_SetInterrupt() writes also into the wake up file. + - Issue #11467: Fix urlparse behavior when handling urls which contains scheme specific part only digits. Patch by Santoso Wijaya. diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c index 42d8dd8..1429770 100644 --- a/Modules/signalmodule.c +++ b/Modules/signalmodule.c @@ -164,6 +164,20 @@ checksignals_witharg(void * unused) } static void +trip_signal(int sig_num) +{ + Handlers[sig_num].tripped = 1; + if (is_tripped) + return; + /* Set is_tripped after setting .tripped, as it gets + cleared in PyErr_CheckSignals() before .tripped. */ + is_tripped = 1; + Py_AddPendingCall(checksignals_witharg, NULL); + if (wakeup_fd != -1) + write(wakeup_fd, "\0", 1); +} + +static void signal_handler(int sig_num) { int save_errno = errno; @@ -180,13 +194,7 @@ signal_handler(int sig_num) if (getpid() == main_pid) #endif { - Handlers[sig_num].tripped = 1; - /* Set is_tripped after setting .tripped, as it gets - cleared in PyErr_CheckSignals() before .tripped. */ - is_tripped = 1; - Py_AddPendingCall(checksignals_witharg, NULL); - if (wakeup_fd != -1) - write(wakeup_fd, "\0", 1); + trip_signal(sig_num); } #ifndef HAVE_SIGACTION @@ -932,9 +940,7 @@ PyErr_CheckSignals(void) void PyErr_SetInterrupt(void) { - is_tripped = 1; - Handlers[SIGINT].tripped = 1; - Py_AddPendingCall((int (*)(void *))PyErr_CheckSignals, NULL); + trip_signal(SIGINT); } void -- cgit v0.12 From 58de6ee8711a079da0b555221ae739d6a69df2f7 Mon Sep 17 00:00:00 2001 From: Nadeem Vawda Date: Tue, 19 Apr 2011 01:38:47 +0200 Subject: Fix sporadic failure in test_startfile. Wait for the child process to terminate before ending the test, so that the regrtest cleanup code doesn't get an error when it tries to delete the temporary CWD. --- Lib/test/test_startfile.py | 5 +++++ Misc/NEWS | 2 ++ 2 files changed, 7 insertions(+) diff --git a/Lib/test/test_startfile.py b/Lib/test/test_startfile.py index 7a003eb..dd505bf 100644 --- a/Lib/test/test_startfile.py +++ b/Lib/test/test_startfile.py @@ -11,6 +11,7 @@ import unittest from test import support import os from os import path +from time import sleep startfile = support.get_attribute(os, 'startfile') @@ -23,6 +24,10 @@ class TestCase(unittest.TestCase): empty = path.join(path.dirname(__file__), "empty.vbs") startfile(empty) startfile(empty, "open") + # Give the child process some time to exit before we finish. + # Otherwise the cleanup code will not be able to delete the cwd, + # because it is still in use. + sleep(0.1) def test_main(): support.run_unittest(TestCase) diff --git a/Misc/NEWS b/Misc/NEWS index 022ad20..8063d02 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -315,6 +315,8 @@ Build Tests ----- +- Fix test_startfile to wait for child process to terminate before finishing. + - Issue #11719: Fix message about unexpected test_msilib skip on non-Windows platforms. Patch by Nadeem Vawda. -- cgit v0.12