Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
6a1b004b
Commit
6a1b004b
authored
Feb 04, 2015
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
asyncio doc: explain how to display ResourceWarning in the debug mode section
parent
2fc23130
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
15 deletions
+24
-15
Doc/library/asyncio-dev.rst
Doc/library/asyncio-dev.rst
+24
-15
No files found.
Doc/library/asyncio-dev.rst
View file @
6a1b004b
...
@@ -14,16 +14,22 @@ This page lists common traps and explains how to avoid them.
...
@@ -14,16 +14,22 @@ This page lists common traps and explains how to avoid them.
Debug mode of asyncio
Debug mode of asyncio
---------------------
---------------------
To enable the debug mode globally, set the environment variable
The implementation of :mod:`asyncio` module has been written for performances.
:envvar:`PYTHONASYNCIODEBUG` to ``1``. To see debug traces, set the log level
To development with asyncio, it's required to enable the debug checks to ease
of the :ref:`asyncio logger <asyncio-logger>` to :py:data:`logging.DEBUG`. The
the development of asynchronous code.
simplest configuration is::
import logging
Setup an application to enable all debug checks:
# ...
logging.basicConfig(level=logging.DEBUG)
Examples of effects of the debug mode:
* Enable the asyncio debug mode globally by setting the environment variable
:envvar:`PYTHONASYNCIODEBUG` to ``1``
* Set the log level of the :ref:`asyncio logger <asyncio-logger>` to
:py:data:`logging.DEBUG`. For example, call
``logging.basicConfig(level=logging.DEBUG)`` at startup.
* Configure the :mod:`warnings` module to display :exc:`ResourceWarning`
warnings. For example, use the ``-Wdefault`` command line option of Python to
display them.
Examples debug checks:
* Log :ref:`coroutines defined but never "yielded from"
* Log :ref:`coroutines defined but never "yielded from"
<asyncio-coroutine-not-scheduled>`
<asyncio-coroutine-not-scheduled>`
...
@@ -33,6 +39,8 @@ Examples of effects of the debug mode:
...
@@ -33,6 +39,8 @@ Examples of effects of the debug mode:
* Log callbacks taking more than 100 ms to be executed. The
* Log callbacks taking more than 100 ms to be executed. The
:attr:`BaseEventLoop.slow_callback_duration` attribute is the minimum
:attr:`BaseEventLoop.slow_callback_duration` attribute is the minimum
duration in seconds of "slow" callbacks.
duration in seconds of "slow" callbacks.
* :exc:`ResourceWarning` warnings are emitted when transports and event loops
are :ref:`not closed explicitly <asyncio-close-transports>`.
.. seealso::
.. seealso::
...
@@ -372,14 +380,15 @@ traceback where the task was created. Example of log in debug mode::
...
@@ -372,14 +380,15 @@ traceback where the task was created. Example of log in debug mode::
:ref:`Detect coroutine objects never scheduled <asyncio-coroutine-not-scheduled>`.
:ref:`Detect coroutine objects never scheduled <asyncio-coroutine-not-scheduled>`.
.. _asyncio-close-transports:
Close transports
Close transports
and event loops
----------------
----------------
----------------
When a transport is no more needed, call its ``close()`` method to release
When a transport is no more needed, call its ``close()`` method to release
resources.
resources.
Event loops must also be closed explicitly.
If a transport
(or an event loop)
is not closed explicitly, a
If a transport
or an event loop
is not closed explicitly, a
:exc:`ResourceWarning` warning will be emitted in its destructor.
The
:exc:`ResourceWarning` warning will be emitted in its destructor.
By default,
:exc:`ResourceWarning` warnings are
hidden by default: use the ``-Wd`` command
:exc:`ResourceWarning` warnings are
ignored. The :ref:`Debug mode of asyncio
line option of Python to show
them.
<asyncio-debug-mode>` section explains how to display
them.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment