-
Notifications
You must be signed in to change notification settings - Fork 458
Support AIOHTTPClient init without running event loop #1271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Sorry, something went wrong.
Lazily instantiates and caches an aiohttp `ClientSession` at the points that it is actually used so that `AIOHTTPClient` can be initialized without a running event loop (e.g. when setting `stripe.default_http_client = stripe.AIOHTTPClient()` at the top level of a module).
Fixes a type checking error by having `AIOHTTPClient`'s `_session` property assert that the `aiohttp` module exists
The `functools.cached_property` decorator did not exist in Python 3.7, so `AIOHTTPClient`'s `_session` has been changed into a regular property that performs caching manually by storing the `ClientSession` object as a member of the instance.
I fixed the typing errors and removed the usage of the |
All reactions
Sorry, something went wrong.
Ensures `AIOHTTPClient`'s `_cached_session` attribute is defined in the initializer.
@richardm-stripe: Bump. |
All reactions
Sorry, something went wrong.
This looks good to me! It will be in Thursday's beta release. Sorry for the silence on this, I appreciate the bump. Thank you for teaching me about about |
All reactions
-
🚀 1 reaction
Sorry, something went wrong.
* Support AIOHTTPClient init without running event loop Lazily instantiates and caches an aiohttp `ClientSession` at the points that it is actually used so that `AIOHTTPClient` can be initialized without a running event loop (e.g. when setting `stripe.default_http_client = stripe.AIOHTTPClient()` at the top level of a module). * Format * Assert aiohttp module is present in AIOHTTPClient Fixes a type checking error by having `AIOHTTPClient`'s `_session` property assert that the `aiohttp` module exists * Remove dependence on cached_property The `functools.cached_property` decorator did not exist in Python 3.7, so `AIOHTTPClient`'s `_session` has been changed into a regular property that performs caching manually by storing the `ClientSession` object as a member of the instance. * Define aiohttp cached session attribute in init Ensures `AIOHTTPClient`'s `_cached_session` attribute is defined in the initializer.
* Support AIOHTTPClient init without running event loop Lazily instantiates and caches an aiohttp `ClientSession` at the points that it is actually used so that `AIOHTTPClient` can be initialized without a running event loop (e.g. when setting `stripe.default_http_client = stripe.AIOHTTPClient()` at the top level of a module). * Format * Assert aiohttp module is present in AIOHTTPClient Fixes a type checking error by having `AIOHTTPClient`'s `_session` property assert that the `aiohttp` module exists * Remove dependence on cached_property The `functools.cached_property` decorator did not exist in Python 3.7, so `AIOHTTPClient`'s `_session` has been changed into a regular property that performs caching manually by storing the `ClientSession` object as a member of the instance. * Define aiohttp cached session attribute in init Ensures `AIOHTTPClient`'s `_cached_session` attribute is defined in the initializer.
1 more reviewer
richardm-stripe
Successfully merging this pull request may close these issues.
Lazily instantiates and caches an aiohttp
ClientSession
at the points in time that it is actually used so thatAIOHTTPClient
can be initialized without a running event loop (e.g. when settingstripe.default_http_client = stripe.AIOHTTPClient()
at the top level of a module).Related to issue #327.