Is your feature request related to a problem? Please describe.
When using the async HTTP clients directly, there is currently no idiomatic way to manage their lifecycle with async with.
In stripe/_http_client.py:
AIOHTTPClient.close() is a no-op
AIOHTTPClient cleanup happens through close_async()
HTTPXClient also exposes close_async()
- async-capable clients do not appear to expose
__aenter__ / __aexit__
That means users need to remember to call close_async() manually instead of using the standard async context-manager pattern.
Describe the solution you'd like
Add async context manager support to async-capable HTTP clients, for example:
async with stripe.AIOHTTPClient() as http_client:
client = stripe.StripeClient("sk_test_...", http_client=http_client)
customer = await client.v1.customers.retrieve_async("cus_123")
Describe alternatives you've considered
Users can call await close_async() manually after using the client, but that is easier to forget and less ergonomic than supporting the standard async with pattern.
Additional context
No response
Is your feature request related to a problem? Please describe.
When using the async HTTP clients directly, there is currently no idiomatic way to manage their lifecycle with
async with.In
stripe/_http_client.py:AIOHTTPClient.close()is a no-opAIOHTTPClientcleanup happens throughclose_async()HTTPXClientalso exposesclose_async()__aenter__/__aexit__That means users need to remember to call
close_async()manually instead of using the standard async context-manager pattern.Describe the solution you'd like
Add async context manager support to async-capable HTTP clients, for example:
Describe alternatives you've considered
Users can call
await close_async()manually after using the client, but that is easier to forget and less ergonomic than supporting the standardasync withpattern.Additional context
No response