Kaydet (Commit) 5819cfa5 authored tarafından Zachary Ware's avatar Zachary Ware

Cosmetic fixes to the 'Develop with asyncio' page

üst 0603d304
...@@ -71,8 +71,8 @@ the event loop. ...@@ -71,8 +71,8 @@ the event loop.
.. seealso:: .. seealso::
See the :ref:`Synchronization primitives <asyncio-sync>` section to The :ref:`Synchronization primitives <asyncio-sync>` section describes ways
synchronize tasks. to synchronize tasks.
.. _asyncio-handle-blocking: .. _asyncio-handle-blocking:
...@@ -112,8 +112,8 @@ Detect coroutine objects never scheduled ...@@ -112,8 +112,8 @@ Detect coroutine objects never scheduled
---------------------------------------- ----------------------------------------
When a coroutine function is called and its result is not passed to When a coroutine function is called and its result is not passed to
:func:`async` or to the :meth:`BaseEventLoop.create_task` method: the execution :func:`async` or to the :meth:`BaseEventLoop.create_task` method, the execution
of the coroutine objet will never be scheduled and it is probably a bug. of the coroutine object will never be scheduled which is probably a bug.
:ref:`Enable the debug mode of asyncio <asyncio-debug-mode>` to :ref:`log a :ref:`Enable the debug mode of asyncio <asyncio-debug-mode>` to :ref:`log a
warning <asyncio-logger>` to detect it. warning <asyncio-logger>` to detect it.
...@@ -147,7 +147,7 @@ Detect exceptions never consumed ...@@ -147,7 +147,7 @@ Detect exceptions never consumed
Python usually calls :func:`sys.displayhook` on unhandled exceptions. If Python usually calls :func:`sys.displayhook` on unhandled exceptions. If
:meth:`Future.set_exception` is called, but the exception is never consumed, :meth:`Future.set_exception` is called, but the exception is never consumed,
:func:`sys.displayhook` is not called. Instead, a :ref:`a log is emitted :func:`sys.displayhook` is not called. Instead, :ref:`a log is emitted
<asyncio-logger>` when the future is deleted by the garbage collector, with the <asyncio-logger>` when the future is deleted by the garbage collector, with the
traceback where the exception was raised. traceback where the exception was raised.
...@@ -195,7 +195,7 @@ traceback where the task was created. Output in debug mode:: ...@@ -195,7 +195,7 @@ traceback where the task was created. Output in debug mode::
raise Exception("not consumed") raise Exception("not consumed")
Exception: not consumed Exception: not consumed
There are different options to fix this issue. The first option is to chain to There are different options to fix this issue. The first option is to chain the
coroutine in another coroutine and use classic try/except:: coroutine in another coroutine and use classic try/except::
@asyncio.coroutine @asyncio.coroutine
...@@ -218,10 +218,12 @@ function:: ...@@ -218,10 +218,12 @@ function::
except Exception: except Exception:
print("exception consumed") print("exception consumed")
See also the :meth:`Future.exception` method. .. seealso::
The :meth:`Future.exception` method.
Chain correctly coroutines Chain coroutines correctly
-------------------------- --------------------------
When a coroutine function calls other coroutine functions and tasks, they When a coroutine function calls other coroutine functions and tasks, they
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment