[issue36295] Need to yield (sleep(0)) twice in asyncio

Andrew Svetlov report at bugs.python.org
Fri Apr 19 04:42:09 EDT 2019


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

In asyncio `await asyncio.sleep(0)` is for switching execution context from the current task to other code. 
There is no guarantee for finishing already running tasks before returning from `asyncio.sleep(0)` call etc.

Also, your code snippet has a logical error. It should not call regular `time.sleep(123)` from a coroutine but use `loop.run_in_executor()` for performing blocking calls

----------

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


More information about the Python-bugs-list mailing list