PyDocs

Nav

Python Runtime Services

aclosing

contextlib

function · Added in 3.10 (source)
  • aclosing(thing)
Async context manager for safely finalizing an asynchronously cleaned-up
resource such as an async generator, calling its ``aclose()`` method.

Code like this:

    async with aclosing(<module>.fetch(<arguments>)) as agen:
        <block>

is equivalent to this:

    agen = <module>.fetch(<arguments>)
    try:
        <block>
    finally:
        await agen.aclose()
0 Examples
No examples for contextlib/aclosing.
See Also
No see-alsos for contextlib/aclosing
0 Notes
No notes for aclosing