[issue36626] asyncio run_forever blocks indefinitely

Andrew Svetlov report at bugs.python.org
Tue Apr 16 06:30:27 EDT 2019


Andrew Svetlov <andrew.svetlov at gmail.com> added the comment:

Not sure about `create_task()`.
Usually you create tasks from async code, where the `_write_to_self()` call is not needed.

Handling writing to self-pipe is not free, starting very many tasks at once can hit performance.

Stopping the loop is another beast, we can perform relative slow operations in such calls.

Thinking more about the issue I'm inclining to reject my initial proposal.

If you want to stop a loop from signal handler you should make `loop.call_soon_threadsafe(loop.stop)` call because `loop.stop()` is not thread-safe operation by definition.

Threadsafe call solves your problem, isn't it?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36626>
_______________________________________


More information about the Python-bugs-list mailing list