diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2014-07-17 20:43:40 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2014-07-17 20:43:40 (GMT) |
commit | fe5649c7b7bf52147480d6b1124a3d8e3597aee3 (patch) | |
tree | 75eddcb18e9c7f4facecbb38732a6678dcad990d /Lib/test/test_asyncio/test_unix_events.py | |
parent | ddc8c8db1cd50d3b86cffbb1070ab32e3a14bbae (diff) | |
download | cpython-fe5649c7b7bf52147480d6b1124a3d8e3597aee3.zip cpython-fe5649c7b7bf52147480d6b1124a3d8e3597aee3.tar.gz cpython-fe5649c7b7bf52147480d6b1124a3d8e3597aee3.tar.bz2 |
Python issue #21645, Tulip issue 192: Rewrite signal handling
Since Python 3.3, the C signal handler writes the signal number into the wakeup
file descriptor and then schedules the Python call using Py_AddPendingCall().
asyncio uses the wakeup file descriptor to wake up the event loop, and relies
on Py_AddPendingCall() to schedule the final callback with call_soon().
If the C signal handler is called in a thread different than the thread of the
event loop, the loop is awaken but Py_AddPendingCall() was not called yet. In
this case, the event loop has nothing to do and go to sleep again.
Py_AddPendingCall() is called while the event loop is sleeping again and so the
final callback is not scheduled immediatly.
This patch changes how asyncio handles signals. Instead of relying on
Py_AddPendingCall() and the wakeup file descriptor, asyncio now only relies on
the wakeup file descriptor. asyncio reads signal numbers from the wakeup file
descriptor to call its signal handler.
Diffstat (limited to 'Lib/test/test_asyncio/test_unix_events.py')
-rw-r--r-- | Lib/test/test_asyncio/test_unix_events.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/test/test_asyncio/test_unix_events.py b/Lib/test/test_asyncio/test_unix_events.py index 0ade7f2..d355def 100644 --- a/Lib/test/test_asyncio/test_unix_events.py +++ b/Lib/test/test_asyncio/test_unix_events.py @@ -42,7 +42,7 @@ class SelectorEventLoopSignalTests(test_utils.TestCase): ValueError, self.loop._check_signal, signal.NSIG + 1) def test_handle_signal_no_handler(self): - self.loop._handle_signal(signal.NSIG + 1, ()) + self.loop._handle_signal(signal.NSIG + 1) def test_handle_signal_cancelled_handler(self): h = asyncio.Handle(mock.Mock(), (), @@ -50,7 +50,7 @@ class SelectorEventLoopSignalTests(test_utils.TestCase): h.cancel() self.loop._signal_handlers[signal.NSIG + 1] = h self.loop.remove_signal_handler = mock.Mock() - self.loop._handle_signal(signal.NSIG + 1, ()) + self.loop._handle_signal(signal.NSIG + 1) self.loop.remove_signal_handler.assert_called_with(signal.NSIG + 1) @mock.patch('asyncio.unix_events.signal') |