]> granicus.if.org Git - python/commitdiff
asyncio doc: close the loop at exit
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 28 Jan 2014 22:32:40 +0000 (23:32 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Tue, 28 Jan 2014 22:32:40 +0000 (23:32 +0100)
Doc/library/asyncio-dev.rst
Doc/library/asyncio-stream.rst
Doc/library/asyncio-task.rst

index 74bbc28a73a4f15ee0afdc24958c7a864a8887dd..73cc38a8304e8f38c390ca896210afa926e271f7 100644 (file)
@@ -169,6 +169,7 @@ operations::
     asyncio.async(test())
     loop.run_forever()
     print("Pending tasks at exit: %s" % asyncio.Task.all_tasks(loop))
+    loop.close()
 
 Expected output::
 
index 22733c1adbf1dc9de1d23e8b13eae354a45f6a54..b5ffdbab9be8c694b96306b69825cd432faa86ce 100644 (file)
@@ -256,6 +256,7 @@ Simple example querying HTTP headers of the URL passed on the command line::
     loop = asyncio.get_event_loop()
     task = asyncio.async(print_http_headers(url))
     loop.run_until_complete(task)
+    loop.close()
 
 Usage::
 
index 81372c52f7c82e00b81254e88f5967e11c2fd8aa..8630f8262d1a2a889caf1cda31e3b5188fba3ec4 100644 (file)
@@ -107,6 +107,7 @@ Example chaining coroutines::
 
     loop = asyncio.get_event_loop()
     loop.run_until_complete(print_sum(1, 2))
+    loop.close()
 
 ``compute()`` is chained to ``print_sum()``: ``print_sum()`` coroutine waits
 until ``compute()`` is completed before returing its result.
@@ -234,6 +235,7 @@ Example combining a :class:`Future` and a :ref:`coroutine function
     asyncio.Task(slow_operation(future))
     loop.run_until_complete(future)
     print(future.result())
+    loop.close()
 
 The coroutine function is responsible of the computation (which takes 1 second)
 and it stores the result into the future. The
@@ -354,6 +356,7 @@ Example executing 3 tasks (A, B, C) in parallel::
 
     loop = asyncio.get_event_loop()
     loop.run_until_complete(asyncio.wait(tasks))
+    loop.close()
 
 Output::