diff --git a/IPython/kernel/channels.py b/IPython/kernel/channels.py index 2457462..3b64865 100644 --- a/IPython/kernel/channels.py +++ b/IPython/kernel/channels.py @@ -209,6 +209,7 @@ class ShellChannel(ZMQSocketChannel): def run(self): """The thread's main activity. Call start() instead.""" self.socket = self.context.socket(zmq.DEALER) + self.socket.linger = 1000 self.socket.setsockopt(zmq.IDENTITY, self.session.bsession) self.socket.connect(self.address) self.stream = zmqstream.ZMQStream(self.socket, self.ioloop) @@ -408,6 +409,7 @@ class IOPubChannel(ZMQSocketChannel): def run(self): """The thread's main activity. Call start() instead.""" self.socket = self.context.socket(zmq.SUB) + self.socket.linger = 1000 self.socket.setsockopt(zmq.SUBSCRIBE,b'') self.socket.setsockopt(zmq.IDENTITY, self.session.bsession) self.socket.connect(self.address) @@ -468,6 +470,7 @@ class StdInChannel(ZMQSocketChannel): def run(self): """The thread's main activity. Call start() instead.""" self.socket = self.context.socket(zmq.DEALER) + self.socket.linger = 1000 self.socket.setsockopt(zmq.IDENTITY, self.session.bsession) self.socket.connect(self.address) self.stream = zmqstream.ZMQStream(self.socket, self.ioloop) @@ -518,7 +521,7 @@ class HBChannel(ZMQSocketChannel): self.poller.unregister(self.socket) self.socket.close() self.socket = self.context.socket(zmq.REQ) - self.socket.setsockopt(zmq.LINGER, 0) + self.socket.linger = 1000 self.socket.connect(self.address) self.poller.register(self.socket, zmq.POLLIN) diff --git a/IPython/kernel/zmq/heartbeat.py b/IPython/kernel/zmq/heartbeat.py index ccfd5dc..2ee6dc2 100644 --- a/IPython/kernel/zmq/heartbeat.py +++ b/IPython/kernel/zmq/heartbeat.py @@ -53,6 +53,7 @@ class Heartbeat(Thread): def run(self): self.socket = self.context.socket(zmq.REP) + self.socket.linger = 1000 c = ':' if self.transport == 'tcp' else '-' self.socket.bind('%s://%s' % (self.transport, self.ip) + c + str(self.port)) while True: diff --git a/IPython/kernel/zmq/kernelapp.py b/IPython/kernel/zmq/kernelapp.py index bb707ce..bf4a07a 100644 --- a/IPython/kernel/zmq/kernelapp.py +++ b/IPython/kernel/zmq/kernelapp.py @@ -298,18 +298,22 @@ class IPKernelApp(BaseIPythonApplication, InteractiveShellApp): # atexit.register(context.term) self.shell_socket = context.socket(zmq.ROUTER) + self.shell_socket.linger = 1000 self.shell_port = self._bind_socket(self.shell_socket, self.shell_port) self.log.debug("shell ROUTER Channel on port: %i" % self.shell_port) self.iopub_socket = context.socket(zmq.PUB) + self.iopub_socket.linger = 1000 self.iopub_port = self._bind_socket(self.iopub_socket, self.iopub_port) self.log.debug("iopub PUB Channel on port: %i" % self.iopub_port) self.stdin_socket = context.socket(zmq.ROUTER) + self.stdin_socket.linger = 1000 self.stdin_port = self._bind_socket(self.stdin_socket, self.stdin_port) self.log.debug("stdin ROUTER Channel on port: %i" % self.stdin_port) self.control_socket = context.socket(zmq.ROUTER) + self.control_socket.linger = 1000 self.control_port = self._bind_socket(self.control_socket, self.control_port) self.log.debug("control ROUTER Channel on port: %i" % self.control_port)