Hello, I am trying to provide a long-lived aiohttp.ClientSession for integrating with an external HTTP API.
I have an async generator for the resource defined as:
async def http_session_factory(*args, **kwargs):
session = ClientSession(*args, **kwargs)
yield session
if not session.closed:
await session.close()
which is then added to the DeclarativeContainer with providers.Resource(http_session_factory).
But, my application is intermittently throwing:
AttributeError: 'NoneType' object has no attribute 'request'"
when trying to use the provided ClientSession instance.
Am I initializing this incorrectly?
Hello, I am trying to provide a long-lived
aiohttp.ClientSessionfor integrating with an external HTTP API.I have an async generator for the resource defined as:
which is then added to the
DeclarativeContainerwithproviders.Resource(http_session_factory).But, my application is intermittently throwing:
AttributeError: 'NoneType' object has no attribute 'request'"when trying to use the provided
ClientSessioninstance.Am I initializing this incorrectly?