Skip to content

[REQ][python][asyncio] Expose extension point for ClientSession (parity with httpx template) #23830

@qiankunli

Description

@qiankunli

Description

The library=asyncio Python template builds aiohttp.ClientSession inline inside RESTClientObject.request(), which leaves no clean extension point for downstream consumers who want to customize the session (e.g. to inject trace_configs for tracing/instrumentation).

By contrast, library=httpx already exposes _create_pool_manager() as a separate method that can be overridden in a subclass.

Request

Bring the asyncio template to parity with httpx by either:

  1. Extracting the ClientSession construction into a _create_pool_manager(self) -> aiohttp.ClientSession method (preferred, matches the httpx template); and/or

  2. Plumbing a trace_configs field on Configuration (similar to how retries is already exposed) and forwarding it to ClientSession(...).

Either change is small and unblocks attaching custom aiohttp.TraceConfig instances without having to patch generated code after every regeneration.

Version

7.22.0

Reference

python/httpx/rest.mustache already has _create_pool_manager() — asyncio template would mirror that shape.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions