🐛 fix(aio): avoid RuntimeError constructing AuthByWebBrowser on Py 3.14 - #2989
Open
13steinj wants to merge 1 commit into
Open
🐛 fix(aio): avoid RuntimeError constructing AuthByWebBrowser on Py 3.14#298913steinj wants to merge 1 commit into
13steinj wants to merge 1 commit into
Conversation
The old "cache asyncio.get_event_loop() as a member, reuse it" idiom is incorrect (between time-of-cache and time-of-use the active event loop can change). As a result of this behavior Python deprecated `asyncio.get_event_loop()` and the event-loop policy system, and started raising a RuntimeError in Python 3.14 when there is no running (or previously-set) event loop, instead of silently creating one. Previously the call was unconditional in a constructor, so constructing outside of a coroutine/event loop now crashes (e.g. in a test). Drop the cached `self._event_loop` entirely and call `asyncio.get_running_loop()` inline at the relevant call-sites that are all only reachable from coroutines anyway. Update every mock within `test/unit/aio/test_auth_webbrowser_async.py` to patch the right method call. Add python 3.14 to the test-aio CI matrix (job is currently disabled as of 7d1356c / snowflakedb#2718, so this has no effect until it's re-enabled).
|
All contributors have signed the CLA ✍️ ✅ |
Author
|
I have read the CLA Document and I hereby sign the CLA |
Author
|
recheck |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The old "cache asyncio.get_event_loop() as a member, reuse it" idiom is incorrect (between time-of-cache and time-of-use the active event loop can change). As a result of this behavior Python deprecated
asyncio.get_event_loop()and the event-loop policy system, and started raising a RuntimeError in Python 3.14 when there is no running (or previously-set) event loop, instead of silently creating one.Previously the call was unconditional in a constructor, so constructing outside of a coroutine/event loop now crashes (e.g. in a test).
Drop the cached
self._event_loopentirely and callasyncio.get_running_loop()inline at the relevant call-sites that are all only reachable from coroutines anyway.Update every mock within
test/unit/aio/test_auth_webbrowser_async.pyto patch the right method call.Add python 3.14 to the test-aio CI matrix (job is currently disabled as of 7d1356c / #2718, so this has no effect until it's re-enabled).
Please answer these questions before submitting your pull requests. Thanks!
What GitHub issue is this PR addressing? Make sure that there is an accompanying issue to your PR.
Fixes SNOW-3890777: AuthByWebBrowser incorrectly caches asyncio event loop #2988
Fill out the following pre-review checklist:
Please describe how your code solves the related issue.
Uses the new idiom for acting on the running event loop.
(Optional) PR for stored-proc connector:
N/A