]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
(Merge 3.4) Python issue #21645, Tulip issue 192: Rewrite signal handling
authorVictor Stinner <victor.stinner@gmail.com>
Thu, 17 Jul 2014 20:45:42 +0000 (22:45 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Thu, 17 Jul 2014 20:45:42 +0000 (22:45 +0200)
commit2fa2c3dfc5d9f0e61a9ffd37b5edeb04e8b8faeb
tree9e236665c8630a1d4c4f284b6fb18c7d3d246430
parentdc2539f957610aa028cc6b60a000e78ec34afb15
parentfe5649c7b7bf52147480d6b1124a3d8e3597aee3
(Merge 3.4) 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.