Issue
Does code below mean anything? If it does, what's the scenario to use it? What's difference if the sleep time is different?
...
while True:
asyncio.get_event_loop().run_until_complete(asyncio.sleep(1))
...
Solution
Copy from one comment which I think answered my question:
run_until_complete() runs not only the given task, but also any other runnable tasks, until the given task completes. The above loop could have a meaning if some tasks were scheduled using asyncio.get_event_loop().create_task(xxx) prior to the loop's execution. In that case the while loop as shown might be designed not to run sleep() (which would indeed be useless), but to give the event loop a time slot of 1s to run, and then (presumably in the loop) do some non-asyncio checks.
Answered By - Bob Lee
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.