Skip to content

fix: APP-scoped httpx.AsyncClient instances are never closed #224

Description

@rorybyrne

The pattern from #5 (GEOIngestor's unclosed httpx.AsyncClient) survives in two DI providers, even though the original site was deleted with the source domain:

  • server/osa/infrastructure/auth/di.py:70
  • server/osa/infrastructure/http/di.py:31

Both create an httpx.AsyncClient at Scope.APP with no Dishka finalizer, so the connection pool is never closed on shutdown.

Fix

Make the providers async generators so Dishka runs the teardown:

@provide(scope=Scope.APP)
async def http_client(self) -> AsyncIterator[httpx.AsyncClient]:
    async with httpx.AsyncClient() as client:
        yield client

Found while verifying #5, which is closed as obsolete in favour of this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinglow-priorityNice to have, no rush

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions