Skip to content

Commit

Permalink
Merge pull request ipython#4118 from pankajp/heartbeart-channel-handl…
Browse files Browse the repository at this point in the history
…e-EINTR

ZMQ heartbeat channel: catch EINTR exceptions and continue.

closes ipython#2310
  • Loading branch information
minrk committed Aug 27, 2013
2 parents 9a43201 + 8f6bae5 commit 49acd63
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions IPython/kernel/zmq/heartbeat.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# Imports
#-----------------------------------------------------------------------------

import errno
import os
import socket
from threading import Thread
Expand Down Expand Up @@ -52,5 +53,13 @@ def run(self):
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

0 comments on commit 49acd63

Please sign in to comment.