]> granicus.if.org Git - python/commitdiff
Close #20652: asyncio doc: close the event loop in run_forever() example. Fix
authorVictor Stinner <victor.stinner@gmail.com>
Mon, 17 Feb 2014 09:54:30 +0000 (10:54 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Mon, 17 Feb 2014 09:54:30 +0000 (10:54 +0100)
also typo. Patch written by Vajrasky Kok.

Doc/library/asyncio-task.rst

index 83d9742eaccb23e6cf850586c9ac443660287617..e7ef172649840d15c306a07c7a287bd094affe70 100644 (file)
@@ -229,7 +229,7 @@ Example combining a :class:`Future` and a :ref:`coroutine function
     @asyncio.coroutine
     def slow_operation(future):
         yield from asyncio.sleep(1)
-        future.set_result('Future in done!')
+        future.set_result('Future is done!')
 
     loop = asyncio.get_event_loop()
     future = asyncio.Future()
@@ -261,7 +261,7 @@ flow::
     @asyncio.coroutine
     def slow_operation(future):
         yield from asyncio.sleep(1)
-        future.set_result('Future in done!')
+        future.set_result('Future is done!')
 
     def got_result(future):
         print(future.result())
@@ -271,7 +271,10 @@ flow::
     future = asyncio.Future()
     asyncio.Task(slow_operation(future))
     future.add_done_callback(got_result)
-    loop.run_forever()
+    try:
+        loop.run_forever()
+    finally:
+        loop.close()
 
 In this example, the future is responsible to display the result and to stop
 the loop.