summaryrefslogtreecommitdiffstats
path: root/Doc/library/asyncio-dev.rst
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-06-22 22:36:11 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-06-22 22:36:11 (GMT)
commit62511fd6d62ef53c1d3d050b478750efc5a7014c (patch)
tree865d42e3d90237832342182cc79999852f2915e0 /Doc/library/asyncio-dev.rst
parent1580fe3fcebcfe0b657281a6a556975c072a5530 (diff)
downloadcpython-62511fd6d62ef53c1d3d050b478750efc5a7014c.zip
cpython-62511fd6d62ef53c1d3d050b478750efc5a7014c.tar.gz
cpython-62511fd6d62ef53c1d3d050b478750efc5a7014c.tar.bz2
asyncio: document the debug mode
Diffstat (limited to 'Doc/library/asyncio-dev.rst')
-rw-r--r--Doc/library/asyncio-dev.rst31
1 files changed, 27 insertions, 4 deletions
diff --git a/Doc/library/asyncio-dev.rst b/Doc/library/asyncio-dev.rst
index 9d6f054..2b3ad94 100644
--- a/Doc/library/asyncio-dev.rst
+++ b/Doc/library/asyncio-dev.rst
@@ -9,6 +9,29 @@ Asynchronous programming is different than classical "sequential" programming.
This page lists common traps and explains how to avoid them.
+.. _asyncio-debug-mode:
+
+Debug mode of asyncio
+---------------------
+
+To enable the debug mode globally, set the environment variable
+:envvar:`PYTHONASYNCIODEBUG` to ``1``. Examples of effects of the debug mode:
+
+* Log :ref:`coroutines defined but never "yielded from"
+ <asyncio-coroutine-not-scheduled>`
+* :meth:`~BaseEventLoop.call_soon` and :meth:`~BaseEventLoop.call_at` methods
+ raise an exception if they are called from the wrong thread.
+* Log the execution time of the selector
+* Log callbacks taking more than 100 ms to be executed. The
+ :attr:`BaseEventLoop.slow_callback_duration` attribute is the minimum
+ duration in seconds of "slow" callbacks.
+
+.. seealso::
+
+ The :meth:`BaseEventLoop.set_debug` method and the :ref:`asyncio logger
+ <asyncio-logger>`.
+
+
.. _asyncio-multithreading:
Concurrency and multithreading
@@ -83,10 +106,10 @@ Detect coroutine objects never scheduled
When a coroutine function is called but not passed to :func:`async` or to the
:class:`Task` constructor, it is not scheduled and it is probably a bug.
-To detect such bug, set the environment variable :envvar:`PYTHONASYNCIODEBUG`
-to ``1``. When the coroutine object is destroyed by the garbage collector, a
-log will be emitted with the traceback where the coroutine function was called.
-See the :ref:`asyncio logger <asyncio-logger>`.
+To detect such bug, :ref:`enable the debug mode of asyncio
+<asyncio-debug-mode>`. When the coroutine object is destroyed by the garbage
+collector, a log will be emitted with the traceback where the coroutine
+function was called. See the :ref:`asyncio logger <asyncio-logger>`.
The debug flag changes the behaviour of the :func:`coroutine` decorator. The
debug flag value is only used when then coroutine function is defined, not when