Issue #28091: Document PEP 525 & PEP 530.
Patch by Eric Appelt.
(grafted from 78c8f450b84ca1864123ec487d363eb151f61a4a)
diff --git a/Doc/library/asyncio-eventloop.rst b/Doc/library/asyncio-eventloop.rst
index bb602c6..fa6a296 100644
--- a/Doc/library/asyncio-eventloop.rst
+++ b/Doc/library/asyncio-eventloop.rst
@@ -88,6 +88,24 @@
This is idempotent and irreversible. No other methods should be called after
this one.
+
+.. coroutinemethod:: AbstractEventLoop.shutdown_asyncgens()
+
+ Schedule all currently open :term:`asynchronous generator` objects to
+ close with an :meth:`~agen.aclose()` call. After calling this method,
+ the event loop will issue a warning whenever a new asynchronous generator
+ is iterated. Should be used to finalize all scheduled asynchronous
+ generators reliably. Example::
+
+ try:
+ loop.run_forever()
+ finally:
+ loop.run_until_complete(loop.shutdown_asyncgens())
+ loop.close()
+
+ .. versionadded:: 3.6
+
+
.. _asyncio-pass-keywords:
Calls
diff --git a/Doc/library/inspect.rst b/Doc/library/inspect.rst
index de0c301..41a784d 100644
--- a/Doc/library/inspect.rst
+++ b/Doc/library/inspect.rst
@@ -318,6 +318,27 @@
.. versionadded:: 3.5
+.. function:: isasyncgenfunction(object)
+
+ Return true if the object is an :term:`asynchronous generator` function,
+ for example::
+
+ >>> async def agen():
+ ... yield 1
+ ...
+ >>> inspect.isasyncgenfunction(agen)
+ True
+
+ .. versionadded:: 3.6
+
+
+.. function:: isasyncgen(object)
+
+ Return true if the object is an :term:`asynchronous generator iterator`
+ created by an :term:`asynchronous generator` function.
+
+ .. versionadded:: 3.6
+
.. function:: istraceback(object)
Return true if the object is a traceback.
diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst
index 2d14a1d..dd51ffd 100644
--- a/Doc/library/sys.rst
+++ b/Doc/library/sys.rst
@@ -594,6 +594,24 @@
.. versionchanged:: 3.6
Added *platform_version*
+
+.. function:: get_asyncgen_hooks()
+
+ Returns an *asyncgen_hooks* object, which is similar to a
+ :class:`~collections.namedtuple` of the form `(firstiter, finalizer)`,
+ where *firstiter* and *finalizer* are expected to be either ``None`` or
+ functions which take an :term:`asynchronous generator iterator` as an
+ argument, and are used to schedule finalization of an asychronous
+ generator by an event loop.
+
+ .. versionadded:: 3.6
+ See :pep:`525` for more details.
+
+ .. note::
+ This function has been added on a provisional basis (see :pep:`411`
+ for details.)
+
+
.. function:: get_coroutine_wrapper()
Returns ``None``, or a wrapper set by :func:`set_coroutine_wrapper`.
@@ -1098,6 +1116,24 @@
implementation platform, rather than part of the language definition, and
thus may not be available in all Python implementations.
+.. function:: set_asyncgen_hooks(firstiter, finalizer)
+
+ Accepts two optional keyword arguments which are callables that accept an
+ :term:`asynchronous generator iterator` as an argument. The *firstiter*
+ callable will be called when an asynchronous generator is iterated for the
+ first time. The *finalizer* will be called when an asynchronous generator
+ is about to be garbage collected.
+
+ .. versionadded:: 3.6
+ See :pep:`525` for more details, and for a reference example of a
+ *finalizer* method see the implementation of
+ ``asyncio.Loop.shutdown_asyncgens`` in
+ :source:`Lib/asyncio/base_events.py`
+
+ .. note::
+ This function has been added on a provisional basis (see :pep:`411`
+ for details.)
+
.. function:: set_coroutine_wrapper(wrapper)
diff --git a/Doc/library/types.rst b/Doc/library/types.rst
index 898b95a..0c5619c 100644
--- a/Doc/library/types.rst
+++ b/Doc/library/types.rst
@@ -104,6 +104,14 @@
.. versionadded:: 3.5
+.. data:: AsyncGeneratorType
+
+ The type of :term:`asynchronous generator`-iterator objects, created by
+ asynchronous generator functions.
+
+ .. versionadded:: 3.6
+
+
.. data:: CodeType
.. index:: builtin: compile