Debian Codegraph @

src/anyio/_core/_resources.py

raw
1 from __future__ import annotations
2
3 from ..abc import AsyncResource
4 from ._tasks import CancelScope
5
6
7 async def aclose_forcefully(resource: AsyncResource) -> None:
8 """
9 Close an asynchronous resource in a cancelled scope.
10
11 Doing this closes the resource without waiting on anything.
12
13 :param resource: the resource to close
14
15 """
16 with CancelScope() as scope:
17 scope.cancel()
18 await resource.aclose()