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

PR: Add Comms to qtconsole #338

Merged
merged 1 commit into from
May 23, 2019
Merged

PR: Add Comms to qtconsole #338

merged 1 commit into from
May 23, 2019

Conversation

@impact27 impact27 force-pushed the comms branch 5 times, most recently from 7b0b792 to a03ab49 Compare May 21, 2019 08:45
@ccordoba12
Copy link
Collaborator

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.

@ccordoba12 ccordoba12 added this to the 4.5 milestone May 21, 2019
@impact27
Copy link
Contributor Author

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?

@ccordoba12
Copy link
Collaborator

Our tests for the Spyder kernel should help you to get started:

https://github.com/spyder-ide/spyder-kernels/blob/master/spyder_kernels/console/tests/test_console_kernel.py

@impact27
Copy link
Contributor Author

I have added the tests

Copy link
Collaborator

@ccordoba12 ccordoba12 left a 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.

@ccordoba12 ccordoba12 merged commit 99e6d83 into jupyter:master May 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants