We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b607be5 commit 77c2e93Copy full SHA for 77c2e93
examples/asyncio-prompt.py
@@ -61,14 +61,14 @@ async def interactive_shell():
61
62
63
def main():
64
- shell = loop.create_task(interactive_shell())
65
-
66
- # This gathers all the async calls, so they can be cancelled at once
67
- tasks = asyncio.gather(print_counter(), return_exceptions=True)
68
69
- loop.run_until_complete(shell)
70
- tasks.cancel()
71
- loop.run_until_complete(tasks)
+ shell_task = loop.create_task(interactive_shell())
+
+ # Gather all the async calls, so they can be cancelled at once
+ background_task = asyncio.gather(print_counter(), return_exceptions=True)
+ loop.run_until_complete(shell_task)
+ background_task.cancel()
+ loop.run_until_complete(background_task)
72
print('Qutting event loop. Bye.')
73
loop.close()
74
0 commit comments