jupyter_client icon indicating copy to clipboard operation
jupyter_client copied to clipboard

KernelClient working in Ipython but not in `Jupyer console --exisiting some_kernel_info.json`

Open mahdi-b opened this issue 1 year ago • 1 comments

The following code works as expected when running from ipython terminal (i.e.; start using the ipython command)

from  jupyter_client import AsyncKernelClient
import json

kernel_config = json.load(open("config/kernel-s3-next.json"))
kc = AsyncKernelClient()
kc.load_connection_info(kernel_config)
kc.execute("1+2")
await kc.get_iopub_msg(timeout=1)

However, running the code from Jupyter console connected to an already running kernel (Jupyer console --existing some_kernel_info.json) returns the following error:

---------------------------------------------------------------------------
Empty                                     Traceback (most recent call last)
Input In [26], in <cell line: 1>()
----> 1 await kc.get_iopub_msg(timeout=1)

File ~/miniconda3/envs/s3-next/lib/python3.8/site-packages/jupyter_client/client.py:129, in KernelClient._async_get_iopub_msg(self, *args, **kwargs)
    127 async def _async_get_iopub_msg(self, *args, **kwargs) -> t.Dict[str, t.Any]:
    128     """Get a message from the iopub channel"""
--> 129     return await self.iopub_channel.get_msg(*args, **kwargs)

File ~/miniconda3/envs/s3-next/lib/python3.8/site-packages/jupyter_client/channels.py:230, in ZMQSocketChannel.get_msg(self, timeout)
    228     return res
    229 else:
--> 230     raise Empty

Empty:

Note that the kernel was started using:

python -m ipykernel_launcher -f some_kernel_info.json

Any ideas as to what is happening here or suggestions to fix the issue would be immensely appreciated.

Thank you!

mahdi-b avatar Jul 21 '22 02:07 mahdi-b

@mahdi-b Did you find anyway to get around this?

sandilya28 avatar Feb 01 '23 16:02 sandilya28