Skip to content

Commit

Permalink
Missing kernel property
Browse files Browse the repository at this point in the history
  • Loading branch information
martinRenou committed Nov 17, 2022
1 parent 6945a0a commit a9556dd
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions ipykernel/comm/comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
class Comm(BaseComm):
"""Class for communicating between a Frontend and a Kernel"""

def __init__(self, *args, **kwargs):
super(Comm, self).__init__(*args, **kwargs)

self.kernel = None

def publish_msg(self, msg_type, data=None, metadata=None, buffers=None, **keys):
"""Helper for sending a comm message on IOPub"""
if not Kernel.initialized():
Expand All @@ -21,14 +26,15 @@ def publish_msg(self, msg_type, data=None, metadata=None, buffers=None, **keys):
metadata = {} if metadata is None else metadata
content = json_clean(dict(data=data, comm_id=self.comm_id, **keys))

kernel = Kernel.instance()
if self.kernel is None:
self.kernel = Kernel.instance()

kernel.session.send(
kernel.iopub_socket,
self.kernel.session.send(
self.kernel.iopub_socket,
msg_type,
content,
metadata=json_clean(metadata),
parent=kernel.get_parent("shell"),
parent=self.kernel.get_parent("shell"),
ident=self.topic,
buffers=buffers,
)
Expand Down

0 comments on commit a9556dd

Please sign in to comment.