summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorNathaniel J. Smith <njs@pobox.com>2018-01-21 14:44:07 (GMT)
committerYury Selivanov <yury@magic.io>2018-01-21 14:44:07 (GMT)
commitfc2f407829d9817ddacccae6944dd0879cfaca24 (patch)
tree1775a28a8181975363798f9b3e7cb2bb100e49a2 /Doc/library
parent1211c9a9897a174b7261ca258cabf289815a40d8 (diff)
downloadcpython-fc2f407829d9817ddacccae6944dd0879cfaca24.zip
cpython-fc2f407829d9817ddacccae6944dd0879cfaca24.tar.gz
cpython-fc2f407829d9817ddacccae6944dd0879cfaca24.tar.bz2
bpo-32591: Add native coroutine origin tracking (#5250)
* Add coro.cr_origin and sys.set_coroutine_origin_tracking_depth * Use coroutine origin information in the unawaited coroutine warning * Stop using set_coroutine_wrapper in asyncio debug mode * In BaseEventLoop.set_debug, enable debugging in the correct thread
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/inspect.rst10
-rw-r--r--Doc/library/sys.rst40
2 files changed, 50 insertions, 0 deletions
diff --git a/Doc/library/inspect.rst b/Doc/library/inspect.rst
index 6be28a2..147e802 100644
--- a/Doc/library/inspect.rst
+++ b/Doc/library/inspect.rst
@@ -34,6 +34,9 @@ provided as convenient choices for the second argument to :func:`getmembers`.
They also help you determine when you can expect to find the following special
attributes:
+.. this function name is too big to fit in the ascii-art table below
+.. |coroutine-origin-link| replace:: :func:`sys.set_coroutine_origin_tracking_depth`
+
+-----------+-------------------+---------------------------+
| Type | Attribute | Description |
+===========+===================+===========================+
@@ -215,6 +218,10 @@ attributes:
+-----------+-------------------+---------------------------+
| | cr_code | code |
+-----------+-------------------+---------------------------+
+| | cr_origin | where coroutine was |
+| | | created, or ``None``. See |
+| | | |coroutine-origin-link| |
++-----------+-------------------+---------------------------+
| builtin | __doc__ | documentation string |
+-----------+-------------------+---------------------------+
| | __name__ | original name of this |
@@ -234,6 +241,9 @@ attributes:
The ``__name__`` attribute of generators is now set from the function
name, instead of the code name, and it can now be modified.
+.. versionchanged:: 3.7
+
+ Add ``cr_origin`` attribute to coroutines.
.. function:: getmembers(object[, predicate])
diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst
index 957d02b..54281a3 100644
--- a/Doc/library/sys.rst
+++ b/Doc/library/sys.rst
@@ -675,6 +675,18 @@ always available.
for details.)
+.. function:: get_coroutine_origin_tracking_depth()
+
+ Get the current coroutine origin tracking depth, as set by
+ func:`set_coroutine_origin_tracking_depth`.
+
+ .. versionadded:: 3.7
+
+ .. note::
+ This function has been added on a provisional basis (see :pep:`411`
+ for details.) Use it only for debugging purposes.
+
+
.. function:: get_coroutine_wrapper()
Returns ``None``, or a wrapper set by :func:`set_coroutine_wrapper`.
@@ -686,6 +698,10 @@ always available.
This function has been added on a provisional basis (see :pep:`411`
for details.) Use it only for debugging purposes.
+ .. deprecated:: 3.7
+ The coroutine wrapper functionality has been deprecated, and
+ will be removed in 3.8. See :issue:`32591` for details.
+
.. data:: hash_info
@@ -1212,6 +1228,26 @@ always available.
This function has been added on a provisional basis (see :pep:`411`
for details.)
+.. function:: set_coroutine_origin_tracking_depth(depth)
+
+ Allows enabling or disabling coroutine origin tracking. When
+ enabled, the ``cr_origin`` attribute on coroutine objects will
+ contain a tuple of (filename, line number, function name) tuples
+ describing the traceback where the coroutine object was created,
+ with the most recent call first. When disabled, ``cr_origin`` will
+ be None.
+
+ To enable, pass a *depth* value greater than zero; this sets the
+ number of frames whose information will be captured. To disable,
+ pass set *depth* to zero.
+
+ This setting is thread-specific.
+
+ .. versionadded:: 3.7
+
+ .. note::
+ This function has been added on a provisional basis (see :pep:`411`
+ for details.) Use it only for debugging purposes.
.. function:: set_coroutine_wrapper(wrapper)
@@ -1252,6 +1288,10 @@ always available.
This function has been added on a provisional basis (see :pep:`411`
for details.) Use it only for debugging purposes.
+ .. deprecated:: 3.7
+ The coroutine wrapper functionality has been deprecated, and
+ will be removed in 3.8. See :issue:`32591` for details.
+
.. function:: _enablelegacywindowsfsencoding()
Changes the default filesystem encoding and errors mode to 'mbcs' and