[issue36626] asyncio run_forever blocks indefinitely
New submission from Dan Timofte : after starting run_forever if all scheduled tasks are consumed run_once will issue a KqueueSelector.select(None) which will block indefinitely : https://www.freebsd.org/cgi/man.cgi?query=select&sektion=2&apropos=0&manpath=FreeBSD+12.0-RELEASE+and+Ports#DESCRIPTION after this new tasks are not being processed, trying to stop event loop with stop() is not working. this blocks immediatly : import asyncio import sys import signal def cb_signal_handler(signum, frame): asyncio.get_event_loop().stop() def main(): signal.signal(signal.SIGINT, cb_signal_handler) # asyncio.get_event_loop().create_task(asyncio.sleep(1)) asyncio.get_event_loop().run_forever() main() With asyncio.sleep uncomment it will block after 4 cycles. -- components: asyncio, macOS messages: 340182 nosy: asvetlov, dantimofte, ned.deily, ronaldoussoren, yselivanov priority: normal severity: normal status: open title: asyncio run_forever blocks indefinitely versions: Python 3.7 ___ Python tracker <https://bugs.python.org/issue36626> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36626] asyncio run_forever blocks indefinitely
Change by Dan Timofte : -- type: -> behavior ___ Python tracker <https://bugs.python.org/issue36626> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36626] asyncio run_forever blocks indefinitely
Dan Timofte added the comment: i will provide a patch, i'll make a pull request next week. a call to self._write_to_self() should also be added to create_task() before it returns . i'll make the correction for this as well. -- ___ Python tracker <https://bugs.python.org/issue36626> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36626] asyncio run_forever blocks indefinitely
Change by Dan Timofte : -- keywords: +patch pull_requests: +12770 stage: -> patch review ___ Python tracker <https://bugs.python.org/issue36626> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36626] asyncio run_forever blocks indefinitely
Dan Timofte added the comment: `loop.call_soon_threadsafe(loop.stop)` solves the problem because it has the write_to_self there. I can use that or call loop._write_to_self() myself before calling loop.stop(). In my code i'm stoping the loop from the exception_handler not signal. The code was a small example i thought of that reproduces the described behaviour. You can close the issue if it's ok for you. -- ___ Python tracker <https://bugs.python.org/issue36626> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com