[Python-checkins] cpython (3.4): Close #20652: asyncio doc: close the event loop in run_forever() example. Fix
larry.hastings
python-checkins at python.org
Mon Mar 17 07:31:48 CET 2014
http://hg.python.org/cpython/rev/36005fe2ab9b
changeset: 89716:36005fe2ab9b
branch: 3.4
user: Victor Stinner <victor.stinner at gmail.com>
date: Mon Feb 17 10:54:30 2014 +0100
summary:
Close #20652: asyncio doc: close the event loop in run_forever() example. Fix
also typo. Patch written by Vajrasky Kok.
files:
Doc/library/asyncio-task.rst | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/Doc/library/asyncio-task.rst b/Doc/library/asyncio-task.rst
--- a/Doc/library/asyncio-task.rst
+++ b/Doc/library/asyncio-task.rst
@@ -229,7 +229,7 @@
@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 @@
@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 @@
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.
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list