]> granicus.if.org Git - python/commitdiff
asyncio doc: update debug traces
authorVictor Stinner <victor.stinner@gmail.com>
Sun, 12 Oct 2014 19:37:16 +0000 (21:37 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Sun, 12 Oct 2014 19:37:16 +0000 (21:37 +0200)
Doc/library/asyncio-dev.rst

index b797d6a78dca6db2ca27585c82f745c0f2f6eb4c..8ec2ff09141cc6439871cfc0d1f1f5d791071cef 100644 (file)
@@ -166,26 +166,35 @@ Example of unhandled exception::
 Output::
 
     Task exception was never retrieved
-    future: <Task finished bug() done at asyncio/coroutines.py:139 exception=Exception('not consumed',)>
+    future: <Task finished coro=<coro() done, defined at asyncio/coroutines.py:139> exception=Exception('not consumed',)>
+    Traceback (most recent call last):
+      File "asyncio/tasks.py", line 237, in _step
+        result = next(coro)
+      File "asyncio/coroutines.py", line 141, in coro
+        res = func(*args, **kw)
+      File "test.py", line 5, in bug
+        raise Exception("not consumed")
+    Exception: not consumed
+
+:ref:`Enable the debug mode of asyncio <asyncio-debug-mode>` to get the
+traceback where the task was created. Output in debug mode::
+
+    Task exception was never retrieved
+    future: <Task finished coro=<bug() done, defined at test.py:3> exception=Exception('not consumed',) created at test.py:8>
     source_traceback: Object created at (most recent call last):
-      File "test.py", line 10, in <module>
+      File "test.py", line 8, in <module>
         asyncio.async(bug())
-      File "asyncio/tasks.py", line 510, in async
-        task = loop.create_task(coro_or_future)
     Traceback (most recent call last):
-      File "asyncio/tasks.py", line 244, in _step
+      File "asyncio/tasks.py", line 237, in _step
         result = next(coro)
-      File "coroutines.py", line 78, in __next__
+      File "asyncio/coroutines.py", line 79, in __next__
         return next(self.gen)
       File "asyncio/coroutines.py", line 141, in coro
         res = func(*args, **kw)
-      File "test.py", line 7, in bug
+      File "test.py", line 5, in bug
         raise Exception("not consumed")
     Exception: not consumed
 
-:ref:`Enable the debug mode of asyncio <asyncio-debug-mode>` to get the
-traceback where the task was created.
-
 There are different options to fix this issue. The first option is to chain to
 coroutine in another coroutine and use classic try/except::
 
@@ -302,16 +311,18 @@ If a pending task is destroyed, the execution of its wrapped :ref:`coroutine
 
 Example of log::
 
+    Task was destroyed but it is pending!
+    task: <Task pending coro=<kill_me() done, defined at test.py:5> wait_for=<Future pending cb=[Task._wakeup()]>>
+
+:ref:`Enable the debug mode of asyncio <asyncio-debug-mode>` to get the
+traceback where the task was created. Example of log in debug mode::
+
     Task was destroyed but it is pending!
     source_traceback: Object created at (most recent call last):
-      File "test.py", line 17, in <module>
+      File "test.py", line 15, in <module>
         task = asyncio.async(coro, loop=loop)
-      File "asyncio/tasks.py", line 510, in async
-        task = loop.create_task(coro_or_future)
-    task: <Task pending kill_me() done at test.py:5 wait_for=<Future pending cb=[Task._wakeup()]>>
+    task: <Task pending coro=<kill_me() done, defined at test.py:5> wait_for=<Future pending cb=[Task._wakeup()] created at test.py:7> created at test.py:15>
 
-:ref:`Enable the debug mode of asyncio <asyncio-debug-mode>` to get the
-traceback where the task was created.
 
 .. seealso::