Skip to content

Context managers leave one httpx client unclosed #3

@saxon134

Description

@saxon134

GlobalRouter.__init__ always constructs both httpx.Client and httpx.AsyncClient, but close() only closes the sync client and aclose() only closes the async client. As a result, with GlobalRouter(...) leaves the async client open, while async with GlobalRouter(...) leaves the sync client open. This can leak connection pools and produce unclosed-client warnings. Close both clients from both shutdown paths, using the appropriate sync/async close operation or lazy creation.

File: src/globalrouter/_client.py

Line: 77

Severity: medium

Summary: close methods leak opposite httpx client

Metadata

Metadata

Assignees

No one assigned

    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