Skip to content

Accepting async context managers for cleanup contexts #11681

@achimnol

Description

@achimnol

Is your feature request related to a problem?

Typing application-level resource init & cleanup contexts with contextlib.asynccontextmanager makes them unusable as aiohttp's cleanup contexts, though the concept is same.

Describe the solution you'd like

Currently cleanup contexts are expected to be async generators, which should have only one yield.
Since it's been a long time after addition of contextlib.asynccontextmanager in the stdlib, I think it should accept them in addition to single-yielding async generators.

Describe alternatives you've considered

Completely changing cleanup contexts from async generators to async context managers would make it incompatible with existing codes, so we need to make it accept both.

Related component

Server

Additional context

No response

Code of Conduct

  • I agree to follow the aio-libs Code of Conduct

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions