-
Notifications
You must be signed in to change notification settings - Fork 199
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
PR: Add Comms to qtconsole #338
Conversation
7b0b792
to
a03ab49
Compare
This is really awesome!! Thanks a lot @impact27 for it! I just have one remark: could you add some tests for this? Just to check that the basic functionality is working as expected. |
Could you help me with setting up a kernel? I am trying to do the following: from qtconsole.qt import QtCore
from qtconsole.manager import QtKernelManager
kernel_manager = QtKernelManager()
kernel_manager.start_kernel()
kernel_client = kernel_manager.client()
kernel_client.start_channels(shell=True, iopub=True)
kernel_client.execute(
"""
class dummy_comm_handler():
def comm_open(self, comm, msg):
self.comm = comm
self.comm.on_msg(self.comm_message)
def comm_message(self, msg):
self.comm.send(msg)
print(msg)
get_ipython().kernel.comm_manager.register_target('test_api', self.comm_open)
"""
)
class dummy_comm_handler(QtCore.QObject):
sig_recieved = QtCore.Signal(dict)
def comm_message(self, msg):
msg_dict = msg['content']['data']
self.sig_recieved.emit(msg_dict)
print(msg_dict)
comm = kernel_client.comm_manager.new_comm('test_api')
handler = dummy_comm_handler()
comm.on_msg(handler.comm_message)
comm.on_close(handler.comm_message)
comm.send({'foo': 5}) But it looks like the ipykernel is not answering. Is there a way to make blocking calls? |
Our tests for the Spyder kernel should help you to get started: |
I have added the tests |
adf735e
to
9f5e214
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@impact27, thanks a lot for taking the time and effort to implement this. It'll make our life in Spyder much more easier from now on.
Add comms to qtconsole.
This is based on:
https://jupyter-notebook.readthedocs.io/en/stable/comms.html
https://jupyter-client.readthedocs.io/en/latest/messaging.html
The code is adapted from:
https://github.com/jupyter/notebook/blob/master/notebook/static/services/kernels/comm.js
https://github.com/ipython/ipykernel/blob/master/ipykernel/comm/manager.py
https://github.com/ipython/ipykernel/blob/master/ipykernel/comm/comm.py