Show More
@@ -32,7 +32,7 b' from zmq.utils import jsonapi' | |||
|
32 | 32 | from zmq.eventloop.ioloop import IOLoop |
|
33 | 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 | 36 | from IPython.config.configurable import Configurable, LoggingConfigurable |
|
37 | 37 | from IPython.utils import io |
|
38 | 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 | 43 | DottedObjectName, CUnicode, Dict, Integer, |
|
44 | 44 | TraitError, |
|
45 | 45 | ) |
|
46 | from IPython.kernel.adapter import adapt | |
|
46 | 47 | from IPython.kernel.zmq.serialize import MAX_ITEMS, MAX_BYTES |
|
47 | 48 | |
|
48 | 49 | #----------------------------------------------------------------------------- |
@@ -299,6 +300,9 b' class Session(Configurable):' | |||
|
299 | 300 | metadata = Dict({}, config=True, |
|
300 | 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 | 306 | # message signature related traits: |
|
303 | 307 | |
|
304 | 308 | key = CBytes(b'', config=True, |
@@ -625,6 +629,8 b' class Session(Configurable):' | |||
|
625 | 629 | io.rprint(msg) |
|
626 | 630 | return |
|
627 | 631 | buffers = [] if buffers is None else buffers |
|
632 | if self.adapt_version: | |
|
633 | msg = adapt(msg, self.adapt_version) | |
|
628 | 634 | to_send = self.serialize(msg, ident) |
|
629 | 635 | to_send.extend(buffers) |
|
630 | 636 | longest = max([ len(s) for s in to_send ]) |
@@ -823,7 +829,10 b' class Session(Configurable):' | |||
|
823 | 829 | message['content'] = msg_list[4] |
|
824 | 830 | |
|
825 | 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 | 837 | def test_msg2obj(): |
|
829 | 838 | am = dict(x=1) |
General Comments 0
You need to be logged in to leave comments.
Login now