From b4ca80e243e768a67d89587035b142473d886134 2013-08-27 17:27:07 From: Pankaj Pandey Date: 2013-08-27 17:27:07 Subject: [PATCH] ZMQ heartbeat: catch EINTR exceptions and continue. The zmq heartbeat channel exits when it encounters an "Interrupted system call", thereby causing the qtconsole to report that it is not responding, despite the console working perfectly fine. Observed in a large Qt application embedding the ipython qtconsole. Fixes #2310 --- diff --git a/IPython/kernel/zmq/heartbeat.py b/IPython/kernel/zmq/heartbeat.py index a2cad92..a018abb 100644 --- a/IPython/kernel/zmq/heartbeat.py +++ b/IPython/kernel/zmq/heartbeat.py @@ -12,6 +12,7 @@ # Imports #----------------------------------------------------------------------------- +import errno import os import socket from threading import Thread @@ -52,5 +53,13 @@ class Heartbeat(Thread): self.socket = self.context.socket(zmq.REP) c = ':' if self.transport == 'tcp' else '-' self.socket.bind('%s://%s' % (self.transport, self.ip) + c + str(self.port)) - zmq.device(zmq.FORWARDER, self.socket, self.socket) - + while True: + try: + zmq.device(zmq.FORWARDER, self.socket, self.socket) + except zmq.ZMQError as e: + if e.errno == errno.EINTR: + continue + else: + raise + else: + break