You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I use the same AsyncCacheControl() object to request a cacheable URL a few times before & then after it expires, I receive a "RuntimeError: Session is closed" error. A minimal script reproducing the error is below. Every 5 seconds it makes a request to a URL which expires after 20 seconds:
import acachecontrol
import asyncio
async def main():
cached_session = acachecontrol.AsyncCacheControl()
URL = 'http://httpbin.org/cache/20'
while True:
print(f"Making request to {URL}")
async with cached_session as cached_session_instance:
async with cached_session_instance.get(URL) as resp:
await resp.json()
await asyncio.sleep(5)
asyncio.run(main())
Script output is that it works for the first 4 requests, then fails on the 5th:
Making request to http://httpbin.org/cache/20
Making request to http://httpbin.org/cache/20
Making request to http://httpbin.org/cache/20
Making request to http://httpbin.org/cache/20
Making request to http://httpbin.org/cache/20
Traceback (most recent call last):
File ".../test_acachecontrol2.py", line 16, in <module>
asyncio.run(main())
File "/usr/lib/python3.9/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
return future.result()
File ".../test_acachecontrol2.py", line 12, in main
async with cached_session_instance.get(URL) as resp:
File "/usr/local/lib/python3.9/dist-packages/acachecontrol/request_context_manager.py", line 40, in __aenter__
async with self.client_session.request(
File "/usr/lib/python3/dist-packages/aiohttp/client.py", line 1117, in __aenter__
self._resp = await self._coro
File "/usr/lib/python3/dist-packages/aiohttp/client.py", line 381, in _request
raise RuntimeError("Session is closed")
RuntimeError: Session is closed
The text was updated successfully, but these errors were encountered:
@dfuhry Thank you for posting this issue. Sorry for such long delay (because of awful war), we'll take a look. Btw, have you had a chance to fix it on your own?
When I use the same AsyncCacheControl() object to request a cacheable URL a few times before & then after it expires, I receive a "RuntimeError: Session is closed" error. A minimal script reproducing the error is below. Every 5 seconds it makes a request to a URL which expires after 20 seconds:
Script output is that it works for the first 4 requests, then fails on the 5th:
The text was updated successfully, but these errors were encountered: