-
-
Notifications
You must be signed in to change notification settings - Fork 396
Fix matplotlib eventloops #1458
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
Conversation
d04171a to
230d5b6
Compare
|
Confirmed by OP in #1454 that this fixes the issue. |
|
Awesome work, thanks for tackling this! |
|
@ianthomas23 , we are using that 'do_one_iteration' function inside our app , if you have any hint on what we should use instead (we need an in process kernel), that would be awesome. |
|
FWIW I have also been using |
|
@jeandet and anybody looking for an alternative - it appears that calling |
No, that is not always the correct stream to flush. Using |
|
@ianthomas23 Thanks - I don't envisage ever using sub-shells in my application, so for me it looks like |
|
@ianthomas23 , @pauldmccarthy , thank you for your help, |
This fixes the use of GUI toolkit eventloops for Matplotlib plots in downstream libraries such as
jupyterlab,qtconsoleandjupyter-consolewhich was broken in the 7.0.0 release. Fixes #1454. Here is a video of it in action:mpl-qt.mp4
The primary change is to ensure that the event loops look for jupyter messages on the correct stream, which isn't necessarily the
shell_stream. But I have also removed various functions (do_one_iteration,process_one,dispatch_queueetc) that passed messages to a shell via a message queue and ensured that only one was processed at a time. This functionality is now achieved by theasyncio_lockinshell_mainand the zmq sockets queue the messages for this without specific extra queues. This in-process kernel tests that were using thedo_one_iterationcode path now use theasyncio_lockroute, the same as the subshell-supporting full kernels. AFAICT no downstream libraries explicitly use this old code anyway.I've implemented the fix for
qt,tk(twice as Windows is different),wxandmacosxeventloops. I've ignored thegtkeventloops asgtk3has been deprecated here for a year and a half, andgtkdoesn't work anyway as the correct name in Matplotlib isgtk4so I assume that nobody has been using this otherwise they would have complained that it is not working.In some situations there are warnings about resources being closed or not being closed when event loops are stopped. These may have been around before, but I don't know. Given that there is work underway in
jupyter_client(jupyter/jupyter_client#1080) it is sensible to wait for that to be finished before looking at similar improvements here and in downstream libraries likeqtconsole.