##// END OF EJS Templates
add topic to display publisher, and fix set_parent for apply_requests
MinRK -
Show More
@@ -204,6 +204,7 b' class EngineFactory(RegistrationFactory):'
204 self.kernel = Kernel(config=self.config, int_id=self.id, ident=self.ident, session=self.session,
204 self.kernel = Kernel(config=self.config, int_id=self.id, ident=self.ident, session=self.session,
205 control_stream=control_stream, shell_streams=shell_streams, iopub_socket=iopub_socket,
205 control_stream=control_stream, shell_streams=shell_streams, iopub_socket=iopub_socket,
206 loop=loop, user_ns=self.user_ns, log=self.log)
206 loop=loop, user_ns=self.user_ns, log=self.log)
207 self.kernel.shell.display_pub.topic = cast_bytes('engine.%i.displaypub' % self.id)
207 self.kernel.start()
208 self.kernel.start()
208
209
209
210
@@ -527,16 +527,18 b' class Kernel(Configurable):'
527 except:
527 except:
528 self.log.error("Got bad msg: %s", parent, exc_info=True)
528 self.log.error("Got bad msg: %s", parent, exc_info=True)
529 return
529 return
530
531 # Set the parent message of the display hook and out streams.
532 self.shell.displayhook.set_parent(parent)
533 self.shell.display_pub.set_parent(parent)
534 sys.stdout.set_parent(parent)
535 sys.stderr.set_parent(parent)
536
530 # pyin_msg = self.session.msg(u'pyin',{u'code':code}, parent=parent)
537 # pyin_msg = self.session.msg(u'pyin',{u'code':code}, parent=parent)
531 # self.iopub_socket.send(pyin_msg)
538 # self.iopub_socket.send(pyin_msg)
532 # self.session.send(self.iopub_socket, u'pyin', {u'code':code},parent=parent)
539 # self.session.send(self.iopub_socket, u'pyin', {u'code':code},parent=parent)
533 sub = self._make_subheader()
540 sub = self._make_subheader()
534 try:
541 try:
535 # allow for not overriding displayhook
536 if hasattr(sys.displayhook, 'set_parent'):
537 sys.displayhook.set_parent(parent)
538 sys.stdout.set_parent(parent)
539 sys.stderr.set_parent(parent)
540 working = self.shell.user_ns
542 working = self.shell.user_ns
541
543
542 prefix = "_"+str(msg_id).replace("-","")+"_"
544 prefix = "_"+str(msg_id).replace("-","")+"_"
@@ -43,7 +43,7 b' from IPython.utils import io'
43 from IPython.utils.jsonutil import json_clean
43 from IPython.utils.jsonutil import json_clean
44 from IPython.utils.path import get_py_filename
44 from IPython.utils.path import get_py_filename
45 from IPython.utils.process import arg_split
45 from IPython.utils.process import arg_split
46 from IPython.utils.traitlets import Instance, Type, Dict, CBool
46 from IPython.utils.traitlets import Instance, Type, Dict, CBool, CBytes
47 from IPython.utils.warn import warn, error
47 from IPython.utils.warn import warn, error
48 from IPython.zmq.displayhook import ZMQShellDisplayHook, _encode_binary
48 from IPython.zmq.displayhook import ZMQShellDisplayHook, _encode_binary
49 from IPython.zmq.session import extract_header
49 from IPython.zmq.session import extract_header
@@ -60,6 +60,7 b' class ZMQDisplayPublisher(DisplayPublisher):'
60 session = Instance(Session)
60 session = Instance(Session)
61 pub_socket = Instance('zmq.Socket')
61 pub_socket = Instance('zmq.Socket')
62 parent_header = Dict({})
62 parent_header = Dict({})
63 topic = CBytes(b'displaypub')
63
64
64 def set_parent(self, parent):
65 def set_parent(self, parent):
65 """Set the parent for outbound messages."""
66 """Set the parent for outbound messages."""
@@ -82,7 +83,7 b' class ZMQDisplayPublisher(DisplayPublisher):'
82 content['metadata'] = metadata
83 content['metadata'] = metadata
83 self.session.send(
84 self.session.send(
84 self.pub_socket, u'display_data', json_clean(content),
85 self.pub_socket, u'display_data', json_clean(content),
85 parent=self.parent_header
86 parent=self.parent_header, ident=self.topic,
86 )
87 )
87
88
88 def clear_output(self, stdout=True, stderr=True, other=True):
89 def clear_output(self, stdout=True, stderr=True, other=True):
@@ -97,7 +98,7 b' class ZMQDisplayPublisher(DisplayPublisher):'
97
98
98 self.session.send(
99 self.session.send(
99 self.pub_socket, u'clear_output', content,
100 self.pub_socket, u'clear_output', content,
100 parent=self.parent_header
101 parent=self.parent_header, ident=self.topic,
101 )
102 )
102
103
103 class ZMQInteractiveShell(InteractiveShell):
104 class ZMQInteractiveShell(InteractiveShell):
General Comments 0
You need to be logged in to leave comments. Login now