Skip to content

Add lifecycle management for Dial clients and pools #92

@kryachkow

Description

@kryachkow

Name and Version

latest

What is the problem this feature will solve?

Dial, AsyncDial, DialClientPool, and AsyncDialClientPool should expose public lifecycle APIs for closing underlying HTTP clients.

What is the feature you are proposing to solve the problem?

Motivation

AsyncDial owns an internal httpx.AsyncClient, but there is no public aclose() or async context manager. Consumers currently need to close internals manually:

await dial._http_client.internal_http_client.aclose()

For pooled clients, AsyncDialClientPool also owns a shared httpx.AsyncClient, but does not expose aclose(), __aenter__, or __aexit__.

Proposed API

For sync clients and pools:

client.close()

with Dial(...) as client:
    ...

For async clients and pools:

await client.aclose()

async with AsyncDial(...) as client:
    ...

For pools:

pool.close()
await async_pool.aclose()

Use Case

Framework applications need deterministic shutdown without relying on private attributes or injecting and managing their own httpx client.

What alternatives have you considered?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    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