jupyter / jupyter_client

Jupyter protocol client APIs
https://jupyter-client.readthedocs.io
BSD 3-Clause "New" or "Revised" License
383 stars 283 forks source link

sync `get_msgs` in channels #890

Open BrenBarn opened 1 year ago

BrenBarn commented 1 year ago

I have an app that uses BlockingKernelClient from the pre-7.0 jupyter client. My code does stuff like client.iopub_channel.get_msgs(), which doesn't work in newer jc versions. Is there a standard migration path for this? Do I have to manually replicate the looping behavior that get_msgs used to provide over get_msg (and also manually wrap it in a run-sync call)?

I see a recent commit ( https://github.com/jupyter/jupyter_client/commit/0986cfee30fc17b585753ebb8ca43ed1d2f11032 ) that seems to restore a sync version of get_msgs to the individual channels. It looks like it's tagged for 8.0. Will I be able to rely on this in 8.0? So far I've just held back on 6.x versions rather than try to figure out how to adapt my code, but if the adaptation will be easier (or unnecessary altogether) in 8.0, then maybe I'll just wait.

I'm finding the async refactoring from 7.x to be kind of a drag. My app is Qt app, and I dare not even consider trying to integrate jc's async event loop with Qt's. So instead I run all my jc stuff in a QThread and do it all synchronously. I'd like to continue doing it that way if possible (unless there is a painless way I don't know about to get the two event loops to work together seamlessly).

blink1073 commented 1 year ago

Hi @BrenBarn, agreed that the 7.x release was a bit awkward as we experimented with how to transition to providing both async and sync versions of the components. You will be able to rely on the sync version of get_msgs moving forward in 8.0+.

For what it is worth, qtconsole is an example of an application that integrates with jupyter_client.

I'd recommend trying to upgrade to the 8.0 prerelease and let us know if you run into any issues.

BrenBarn commented 1 year ago

Thanks for the info. I looked at qtconsole initially when writing my app but found it difficult to trace through the logic of how it actually used jupyter_client. Perhaps I will take another look.