From df2592cb1862430392c5b30f200487fdbeca6812 2012-04-18 22:30:50 From: MinRK Date: 2012-04-18 22:30:50 Subject: [PATCH] close KernelManager channel sockets when they stop Otherwise there are dangling sockets on the Context, which cannot terminate. --- diff --git a/IPython/zmq/kernelmanager.py b/IPython/zmq/kernelmanager.py index 974b3fe..a350866 100644 --- a/IPython/zmq/kernelmanager.py +++ b/IPython/zmq/kernelmanager.py @@ -200,6 +200,10 @@ class ShellSocketChannel(ZMQSocketChannel): self.stream = zmqstream.ZMQStream(self.socket, self.ioloop) self.stream.on_recv(self._handle_recv) self._run_loop() + try: + self.socket.close() + except: + pass def stop(self): self.ioloop.stop() @@ -390,6 +394,10 @@ class SubSocketChannel(ZMQSocketChannel): self.stream = zmqstream.ZMQStream(self.socket, self.ioloop) self.stream.on_recv(self._handle_recv) self._run_loop() + try: + self.socket.close() + except: + pass def stop(self): self.ioloop.stop() @@ -452,6 +460,11 @@ class StdInSocketChannel(ZMQSocketChannel): self.stream = zmqstream.ZMQStream(self.socket, self.ioloop) self.stream.on_recv(self._handle_recv) self._run_loop() + try: + self.socket.close() + except: + pass + def stop(self): self.ioloop.stop() @@ -575,6 +588,10 @@ class HBSocketChannel(ZMQSocketChannel): # and close/reopen the socket, because the REQ/REP cycle has been broken self._create_socket() continue + try: + self.socket.close() + except: + pass def pause(self): """Pause the heartbeat."""