Skip to content

Add a public method to close the underlying httpx.AsyncClient #28

Closed

Description

@townsmcp

SaicApiClient creates and owns an httpx.AsyncClient, but neither it nor AbstractSaicApi exposes a way to close it. A consumer that constructs a SaicApi, experiences a failed login (or simply finishes using the client), and then tries to clean up has no supported way to release the transport — so the underlying HTTP client stays open until garbage collection or process exit. Under repeated failed logins this leaks connections.
Would you accept a small, additive PR adding async def close() to both SaicApiClient (closing its httpx.AsyncClient via aclose()) and AbstractSaicApi (delegating to the client)? It's backward-compatible — nothing existing changes. Happy to open it. Context: this came up in the mg-saic-ha Home Assistant integration, which currently has to reach the private client to close it.

Activity

  1. changed the title [-]No public method to close the underlying httpx.AsyncClient[/-] [+]Add a public method to close the underlying httpx.AsyncClient[/+] on Jul 19, 2026
  2. nanomad commented on Oct 17, 2026

    @nanomad
    Contributor

    Accepted. Added close() to SaicApiClient and AbstractSaicApi in #31. Thanks for the suggestion.

  3. nanomad commented on Oct 17, 2026

    @nanomad
    Contributor

    @townsmcp Thank you for the suggestion and for the context from mg-saic-ha. The change is merged and will go out in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions