Skip to content

Sync client lacks close()/context manager; requests.Session leaks #155

Description

@martinkersner

Summary

The async client exposes aclose / __aenter__ / __aexit__ and closes its httpx client, but the sync API never exposes close() / __enter__ / __exit__ and never closes the underlying requests.Session. The session and its connection pool live until GC — an asymmetry with the async side and a resource leak in long-lived processes.

Location

datamaxi/api.py:73 (session created; never closed)

Fix

Add to API (and surface through Resource / Datamaxi):

def close(self):
    self.session.close()

def __enter__(self):
    return self

def __exit__(self, *exc):
    self.close()

So users can do with Datamaxi(...) as client: ..., mirroring async with AsyncDatamaxi(...).


Surfaced during a pythonic-idiom review of the SDK.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingclaude-foundSurfaced by Claude

Type

No type

Fields

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