Closes #21921: Fix ResourceWarning in the asyncio examples: close the event

loop at exit. Patch written by Vajrasky Kok (I modified also the "hello world"
example using a coroutine).
This commit is contained in:
Victor Stinner 2014-07-05 15:38:59 +02:00
parent a9acbe82e7
commit 63b21a8ffa
2 changed files with 12 additions and 3 deletions

View file

@ -89,7 +89,10 @@ Print ``"Hello World"`` every two seconds using a coroutine::
yield from asyncio.sleep(2)
loop = asyncio.get_event_loop()
loop.run_until_complete(greet_every_two_seconds())
try:
loop.run_until_complete(greet_every_two_seconds())
finally:
loop.close()
.. seealso::