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).
diff --git a/Doc/library/asyncio-task.rst b/Doc/library/asyncio-task.rst
index f1894da..3544657 100644
--- a/Doc/library/asyncio-task.rst
+++ b/Doc/library/asyncio-task.rst
@@ -89,7 +89,10 @@
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::