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

don't try to start a new event loop in WebAgg when in an ipykernel #24120

Merged
merged 3 commits into from Dec 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 14 additions & 2 deletions lib/matplotlib/backends/backend_webagg.py
Expand Up @@ -245,6 +245,14 @@ def random_ports(port, n):

@classmethod
def start(cls):
import asyncio
try:
asyncio.get_running_loop()
except RuntimeError:
pass
else:
cls.started = True

if cls.started:
return

Expand Down Expand Up @@ -286,8 +294,12 @@ def ipython_inline_display(figure):
import tornado.template

WebAggApplication.initialize()
if not webagg_server_thread.is_alive():
webagg_server_thread.start()
import asyncio
try:
asyncio.get_running_loop()
except RuntimeError:
if not webagg_server_thread.is_alive():
webagg_server_thread.start()

fignum = figure.number
tpl = Path(core.FigureManagerWebAgg.get_static_file_path(),
Expand Down