Skip to content

Commit 8ed9964

Browse files
authored
Merge pull request #985 from minrk/xpub
handle XPUB socket type in kernel protocol
2 parents 07ccc38 + 2be3890 commit 8ed9964

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

ipyparallel/engine/app.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# Copyright (c) IPython Development Team.
77
# Distributed under the terms of the Modified BSD License.
88
import asyncio
9+
import inspect
910
import json
1011
import os
1112
import signal
@@ -17,6 +18,7 @@
1718

1819
import ipykernel
1920
import zmq
21+
from ipykernel.iostream import IOPubThread
2022
from ipykernel.kernelapp import IPKernelApp
2123
from ipykernel.zmqshell import ZMQInteractiveShell
2224
from IPython.core.profiledir import ProfileDir
@@ -667,17 +669,18 @@ def urls(key):
667669

668670
# create iopub stream:
669671
iopub_addr = url('iopub')
670-
iopub_socket = self.iopub_socket = ctx.socket(zmq.PUB)
672+
thread_params = {}
673+
if 'session' in inspect.signature(IOPubThread).parameters:
674+
iopub_socket_type = zmq.XPUB
675+
thread_params["session"] = self.session
676+
else:
677+
iopub_socket_type = zmq.PUB
678+
iopub_socket = self.iopub_socket = ctx.socket(iopub_socket_type)
671679
iopub_socket.SNDHWM = 0
672680
iopub_socket.setsockopt(zmq.IDENTITY, identity)
673681
connect(iopub_socket, iopub_addr)
674-
try:
675-
from ipykernel.iostream import IOPubThread
676-
except ImportError:
677-
pass
678-
else:
679-
iopub_socket = IOPubThread(iopub_socket)
680-
iopub_socket.start()
682+
iopub_socket = IOPubThread(iopub_socket, **thread_params)
683+
iopub_socket.start()
681684

682685
# disable history:
683686
self.config.HistoryManager.hist_file = ':memory:'

0 commit comments

Comments
 (0)