Show More
@@ -32,7 +32,7 b' from zmq.utils import jsonapi' | |||||
32 | from zmq.eventloop.ioloop import IOLoop |
|
32 | from zmq.eventloop.ioloop import IOLoop | |
33 | from zmq.eventloop.zmqstream import ZMQStream |
|
33 | from zmq.eventloop.zmqstream import ZMQStream | |
34 |
|
34 | |||
35 | from IPython.core.release import kernel_protocol_version |
|
35 | from IPython.core.release import kernel_protocol_version, kernel_protocol_version_info | |
36 | from IPython.config.configurable import Configurable, LoggingConfigurable |
|
36 | from IPython.config.configurable import Configurable, LoggingConfigurable | |
37 | from IPython.utils import io |
|
37 | from IPython.utils import io | |
38 | from IPython.utils.importstring import import_item |
|
38 | from IPython.utils.importstring import import_item | |
@@ -43,6 +43,7 b' from IPython.utils.traitlets import (CBytes, Unicode, Bool, Any, Instance, Set,' | |||||
43 | DottedObjectName, CUnicode, Dict, Integer, |
|
43 | DottedObjectName, CUnicode, Dict, Integer, | |
44 | TraitError, |
|
44 | TraitError, | |
45 | ) |
|
45 | ) | |
|
46 | from IPython.kernel.adapter import adapt | |||
46 | from IPython.kernel.zmq.serialize import MAX_ITEMS, MAX_BYTES |
|
47 | from IPython.kernel.zmq.serialize import MAX_ITEMS, MAX_BYTES | |
47 |
|
48 | |||
48 | #----------------------------------------------------------------------------- |
|
49 | #----------------------------------------------------------------------------- | |
@@ -299,6 +300,9 b' class Session(Configurable):' | |||||
299 | metadata = Dict({}, config=True, |
|
300 | metadata = Dict({}, config=True, | |
300 | help="""Metadata dictionary, which serves as the default top-level metadata dict for each message.""") |
|
301 | help="""Metadata dictionary, which serves as the default top-level metadata dict for each message.""") | |
301 |
|
302 | |||
|
303 | # if 0, no adapting to do. | |||
|
304 | adapt_version = Integer(0) | |||
|
305 | ||||
302 | # message signature related traits: |
|
306 | # message signature related traits: | |
303 |
|
307 | |||
304 | key = CBytes(b'', config=True, |
|
308 | key = CBytes(b'', config=True, | |
@@ -625,6 +629,8 b' class Session(Configurable):' | |||||
625 | io.rprint(msg) |
|
629 | io.rprint(msg) | |
626 | return |
|
630 | return | |
627 | buffers = [] if buffers is None else buffers |
|
631 | buffers = [] if buffers is None else buffers | |
|
632 | if self.adapt_version: | |||
|
633 | msg = adapt(msg, self.adapt_version) | |||
628 | to_send = self.serialize(msg, ident) |
|
634 | to_send = self.serialize(msg, ident) | |
629 | to_send.extend(buffers) |
|
635 | to_send.extend(buffers) | |
630 | longest = max([ len(s) for s in to_send ]) |
|
636 | longest = max([ len(s) for s in to_send ]) | |
@@ -823,7 +829,10 b' class Session(Configurable):' | |||||
823 | message['content'] = msg_list[4] |
|
829 | message['content'] = msg_list[4] | |
824 |
|
830 | |||
825 | message['buffers'] = msg_list[5:] |
|
831 | message['buffers'] = msg_list[5:] | |
826 | return message |
|
832 | # print("received: %s: %s\n %s" % (message['msg_type'], message['header'], message['content'])) | |
|
833 | # adapt to the current version | |||
|
834 | return adapt(message) | |||
|
835 | # print("adapted: %s: %s\n %s" % (adapted['msg_type'], adapted['header'], adapted['content'])) | |||
827 |
|
836 | |||
828 | def test_msg2obj(): |
|
837 | def test_msg2obj(): | |
829 | am = dict(x=1) |
|
838 | am = dict(x=1) |
General Comments 0
You need to be logged in to leave comments.
Login now