This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author hidmic
Recipients asvetlov, hidmic, paul.moore, steve.dower, tim.golden, yselivanov, zach.ware
Date 2021-01-12.21:43:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1610487833.61.0.883604582572.issue42913@roundup.psfhosted.org>
In-reply-to
Content
asyncio.ProactorEventLoop uses a socket.socketpair and signal.set_wakeup_fd to wake up a loop that's polling I/O. However it does so with no consideration for file descriptors previously set (i.e. no signal number forwarding). Either by user code or by another instance of asyncio.ProactorEventLoop.

The following snippet is enough for the above to cause the loop to hang forever:

import asyncio
import gc

asyncio.set_event_loop(asyncio.ProactorEventLoop())
asyncio.set_event_loop(asyncio.ProactorEventLoop())
gc.collect()
asyncio.get_event_loop().run_forever()


The first asyncio.ProactorEventLoop instance sets a signal wakeup file descriptor on construction (see https://github.com/python/cpython/blob/187f76def8a5bd0af7ab512575cad30cfe624b05/Lib/asyncio/proactor_events.py#L632). The second instances does the same, dropping the file descriptor set by the first one (not good, not necessarily bad). When the garbage collector purges the first instance, signal wakeups are disabled completely (see https://github.com/python/cpython/blob/187f76def8a5bd0af7ab512575cad30cfe624b05/Lib/asyncio/proactor_events.py#L679). The loop cannot be interrupted with Ctrl+C anymore (bad).
History
Date User Action Args
2021-01-12 21:43:53hidmicsetrecipients: + hidmic, paul.moore, tim.golden, asvetlov, zach.ware, yselivanov, steve.dower
2021-01-12 21:43:53hidmicsetmessageid: <1610487833.61.0.883604582572.issue42913@roundup.psfhosted.org>
2021-01-12 21:43:53hidmiclinkissue42913 messages
2021-01-12 21:43:53hidmiccreate