Skip to content

🐛 fix(aio): avoid RuntimeError constructing AuthByWebBrowser on Py 3.14 - #2989

Open
13steinj wants to merge 1 commit into
snowflakedb:mainfrom
chicagotrading:fix/py314-webbrowser-event-loop
Open

🐛 fix(aio): avoid RuntimeError constructing AuthByWebBrowser on Py 3.14#2989
13steinj wants to merge 1 commit into
snowflakedb:mainfrom
chicagotrading:fix/py314-webbrowser-event-loop

Conversation

@13steinj

@13steinj 13steinj commented Aug 4, 2026

Copy link
Copy Markdown

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 / #2718, so this has no effect until it's re-enabled).

Please answer these questions before submitting your pull requests. Thanks!

  1. 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

  2. Fill out the following pre-review checklist:

    • I am adding a new automated test(s) to verify correctness of my new code
      • I don't know if this counts or not because some of these test are disabled in CI but some downstream consumers end up running your tests anyway.
    • I am adding new logging messages
    • I am adding a new telemetry message
    • I am modifying authorization mechanisms
    • I am adding new credentials
    • I am modifying OCSP code
    • I am adding a new dependency
  3. Please describe how your code solves the related issue.

    Uses the new idiom for acting on the running event loop.

  4. (Optional) PR for stored-proc connector:
    N/A

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).
@13steinj
13steinj requested a review from a team as a code owner August 4, 2026 19:59
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@13steinj

13steinj commented Aug 4, 2026

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@13steinj

13steinj commented Aug 4, 2026

Copy link
Copy Markdown
Author

recheck

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

Successfully merging this pull request may close these issues.

SNOW-3890777: AuthByWebBrowser incorrectly caches asyncio event loop

1 participant