cpython/Doc/reference
Joongi Kim 6e8dcdaaa4
bpo-41229: Update docs for explicit aclose()-required cases and add contextlib.aclosing() method (GH-21545)
This is a PR to:

 * Add `contextlib.aclosing` which ia analogous to `contextlib.closing` but for async-generators with an explicit test case for [bpo-41229]()
 * Update the docs to describe when we need explicit `aclose()` invocation.

which are motivated by the following issues, articles, and examples:

 * [bpo-41229]()
 * https://github.com/njsmith/async_generator
 * https://vorpus.org/blog/some-thoughts-on-asynchronous-api-design-in-a-post-asyncawait-world/#cleanup-in-generators-and-async-generators
 * https://www.python.org/dev/peps/pep-0533/
 * https://github.com/achimnol/aiotools/blob/ef7bf0cea7af/src/aiotools/context.py#L152

Particuarly regarding [PEP-533](https://www.python.org/dev/peps/pep-0533/), its acceptance (`__aiterclose__()`) would make this little addition of `contextlib.aclosing()` unnecessary for most use cases, but until then this could serve as a good counterpart and analogy to `contextlib.closing()`. The same applies for `contextlib.closing` with `__iterclose__()`.
Also, still there are other use cases, e.g., when working with non-generator objects with `aclose()` methods.
2020-11-02 00:02:48 -08:00
..
compound_stmts.rst [doc] Remove mention of async and await as soft keywords (GH-22144) 2020-10-12 14:52:30 +01:00
datamodel.rst bpo-6761: Enhance __call__ documentation (GH-7987) 2020-10-27 17:18:57 +01:00
executionmodel.rst Doc: Add -m reference in context of code execution (GH-16045) 2019-09-12 14:19:06 +01:00
expressions.rst bpo-41229: Update docs for explicit aclose()-required cases and add contextlib.aclosing() method (GH-21545) 2020-11-02 00:02:48 -08:00
grammar.rst bpo-40939: Use the new grammar for the grammar specification documentation (GH-19969) 2020-07-27 11:20:36 -07:00
import.rst bpo-35181: Correct importlib documentation for some module attributes (GH-15190) 2020-10-21 14:17:35 -07:00
index.rst
introduction.rst bpo-41762: Fix usage of productionlist markup in the doc (GH-22281) 2020-09-18 09:10:15 +02:00
lexical_analysis.rst bpo-41762: Fix usage of productionlist markup in the doc (GH-22281) 2020-09-18 09:10:15 +02:00
simple_stmts.rst Doc: Remove old Python version from future stmt (GH-21802) 2020-10-21 14:45:13 +09:00
toplevel_components.rst bpo-41762: Fix usage of productionlist markup in the doc (GH-22281) 2020-09-18 09:10:15 +02:00