0.8.0 version regression: "aiohttp-client-cache" prevents Pytest session from finishing (tests pass, but session never exits) #146
-
0.7.3 version works fine, but when I install 0.8.0, my Pytest tests results in:
In other words, after all tests the session hangs forever. Were there any forever running tasks introduces in the 0.8.0 version? I even do not understand how to debug this. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 4 replies
-
I believe a deadlock may be introduced somewhere in the last commits, e.g. 931f521 I will try to make a reproducible small code sample... |
Beta Was this translation helpful? Give feedback.
-
Reproducible code sample:from aiohttp_client_cache import CachedSession, SQLiteBackend
import pytest
@pytest.mark.asyncio()
async def test_client_cache():
async with CachedSession(cache=SQLiteBackend('demo_cache')) as session:
await session.get('http://httpbin.org/delay/1') Dependencies (
|
Beta Was this translation helpful? Give feedback.
-
I'm surprised the CI tests didn't catch that, but you're right, it must be a deadlock. My best guess is that it's stuck on closing the database connection when the I am a little busy this week, but I will try to get this fixed soon. |
Beta Was this translation helpful? Give feedback.
-
I think it was actually the opposite problem: the database connection wasn't getting closed, and leaving that connection open seems to cause problems when the test session ends, presumably when it's deleting resources from memory. I made some changes in #148 that I believe will fix this. Changes are in main. Give that a try and let me know if that works for you. I still don't 100% understand the problem, though, because it doesn't seem to occur within the destructor of any of the classes within aiohttp-client-cache. Also, it appears to be a threading lock that's stuck, not an async lock. It's in threading._shutdown(), but I couldn't get any error context beyond that. In aiohttp-client-cache 0.8, thread locks are were no longer needed and were swapped out for async locks. That leaves Very weird! I am probably missing something about how |
Beta Was this translation helpful? Give feedback.
I think it was actually the opposite problem: the database connection wasn't getting closed, and leaving that connection open seems to cause problems when the test session ends, presumably when it's deleting resources from memory. I made some changes in #148 that I believe will fix this. Changes are in main. Give that a try and let me know if that works for you.
I still don't 100% understand the problem, though, because it doesn't seem to occur within the destructor of any of the classes within aiohttp-client-cache. Also, it appears to be a threading lock that's stuck, not an async lock. It's in threading._shutdown(), but I couldn't get any error context beyond that. In aiohttp-client-cac…