Skip to content

Context managers leave the companion HTTP client open #44

@saxon134

Description

@saxon134

GlobalRouter.__init__ always creates both self._client and self._async_client, but close() only closes the sync client and aclose() only closes the async client. A sync with GlobalRouter(...) therefore leaves the async client's connection pool open, while async with GlobalRouter(...) leaves the sync client open. This is directly reproducible with c = GlobalRouter(api_key='x'); c.close(); assert c._async_client.is_closed, which fails. The lifecycle methods should close both clients, or the SDK should lazily create only the client flavor being used.

File: src/globalrouter/_client.py

Line: 77

Severity: medium

Summary: unclosed companion client in globalrouter lifecycle

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