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

Fix event loop handling #362

Merged
merged 2 commits into from
Sep 27, 2023
Merged

Conversation

blink1073
Copy link
Contributor

@blink1073 blink1073 added the bug label Sep 26, 2023
@blink1073
Copy link
Contributor Author

cc @maartenbreddels this was a nice typing cleanup. :)

@blink1073
Copy link
Contributor Author

I'll make the release tomorrow.

@blink1073 blink1073 merged commit 3b353d7 into jupyter:main Sep 27, 2023
20 checks passed
@blink1073 blink1073 deleted the fix-event-loop-handling branch September 27, 2023 01:54
@maartenbreddels
Copy link

Nice indeed :)

@samuelan
Copy link

samuelan commented Oct 1, 2023

I have some codes that use run_sync(coroutine_a), and with jupyter_core==5.3.2, it stops working. The code complains
File "/opt/conda/lib/python3.9/site-packages/jupyter_core/utils/init.py", line 168, in wrapped
return loop.run_until_complete(inner)
File "/opt/conda/lib/python3.9/asyncio/base_events.py", line 623, in run_until_complete
self._check_running()
File "/opt/conda/lib/python3.9/asyncio/base_events.py", line 583, in _check_running
raise RuntimeError('This event loop is already running')
RuntimeError: This event loop is already running

once I revert to 5.3.1 version. It started to work. Do codes that depend on jupyter_core need to change after this change, any documentation?

@blink1073
Copy link
Contributor Author

Hi @samuelan, can you please open a new issue with some code that reproduces the error?

@samuelan
Copy link

samuelan commented Oct 2, 2023

Hi @samuelan, can you please open a new issue with some code that reproduces the error?

Sure. It's a bit involved. I will try a repro with simplified codes, and circle back when I get it.

Comment on lines +163 to +165
try:
loop = asyncio.get_event_loop()
except RuntimeError:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you actually want loop = asyncio.get_running_loop() here?

According to https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.get_event_loop this is deprecated in python 3.12 and will emit https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.get_event_loop. This causes some test failures (e.g. in jupyter_client).

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I suggested above does fix the test failures in jupyter_client I was getting, at the expense of causing other test failures in jupyter_client.

The only thing that makes the jupyter_client testsuite pass (on python 3.12) is reverting the current PR. I'll downgrade to jupyter_core 5.3.1 for the time being.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the heads up @tornaria, I opened #367

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