Skip to content
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

HTTPSPublicKeyRetriever caches asyncio event loop - pytest-asyncio issues #143

Open
tildedave opened this issue Jun 16, 2021 · 0 comments
Open

Comments

@tildedave
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant