HTTPSPublicKeyRetriever caches asyncio event loop - pytest-asyncio issues
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 55/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- python
- Domain
- authentication
Research direction
Start in atlassian_jwt_auth/contrib/aiohttp/key.py around the HTTPSPublicKeyRetriever session handling, then reproduce the failure with two pytest-asyncio tests using separate event loops. Determine how the cached _class_session can be invalidated without relying on the deprecated client.loop attribute; done means both tests complete without reusing a session tied to a closed loop.
Written by the indexing model from the issue text.
Description
Hey there. I'm using atlassian_jwt_auth in an ayncio context; specifically using pytest-asyncio for the event loop creation. By default this library creates a new event loop for each test. (This is my desired behavior.)
However when running two tests that both utilize the HTTPSPublicKeyRetriever, the second test fails because the cached HTTPSPublicKeyRetriever._class_session is used with a now-shutdown event loop.
I've gotten around this with a fixture like so:
@pytest.fixture(autouse=True)
async def clean_https_session():
yield
await HTTPSPublicKeyRetriever._class_session.close()
HTTPSPublicKeyRetriever._class_session = None
However this feels sort of wacky. Ideally I'd like the library to detect this and invalidate the _class_session either when the loop is shut down or when the session is gotten.
Adding a conditional here of client.loop != self.loop fixes the issue, but client.loop is deprecated in aiohttp and actually has been removed in the newest master branch.
- Dominant language
- Python
- Stars
- 26
- Forks
- 19
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from atlassian/asap-authentication-python
-
The HTTPSMultiRepositoryPublicKeyRetriever does use other server when it gets a ConnectionError Open
Difficulty 3/5 1-2 days Newbie friendliness 45/100
atlassian/asap-authentication-python#104 · 1 reaction ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 42/100
atlassian/asap-authentication-python#40 · 1 comment ·
All issues in atlassian/asap-authentication-python
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100