Show More
@@ -17,6 +17,7 b' TODO' | |||||
17 |
|
17 | |||
18 | # Standard library imports. |
|
18 | # Standard library imports. | |
19 | import atexit |
|
19 | import atexit | |
|
20 | import errno | |||
20 | from Queue import Queue, Empty |
|
21 | from Queue import Queue, Empty | |
21 | from subprocess import Popen |
|
22 | from subprocess import Popen | |
22 | import signal |
|
23 | import signal | |
@@ -108,6 +109,19 b' class ZmqSocketChannel(Thread):' | |||||
108 | raise InvalidPortNumber(message) |
|
109 | raise InvalidPortNumber(message) | |
109 | self._address = address |
|
110 | self._address = address | |
110 |
|
111 | |||
|
112 | def _run_loop(self): | |||
|
113 | """Run my loop, ignoring EINTR events in the poller""" | |||
|
114 | while True: | |||
|
115 | try: | |||
|
116 | self.ioloop.start() | |||
|
117 | except zmq.ZMQError as e: | |||
|
118 | if e.errno == errno.EINTR: | |||
|
119 | continue | |||
|
120 | else: | |||
|
121 | raise | |||
|
122 | else: | |||
|
123 | break | |||
|
124 | ||||
111 | def stop(self): |
|
125 | def stop(self): | |
112 | """Stop the channel's activity. |
|
126 | """Stop the channel's activity. | |
113 |
|
127 | |||
@@ -178,7 +192,7 b' class XReqSocketChannel(ZmqSocketChannel):' | |||||
178 | self.iostate = POLLERR|POLLIN |
|
192 | self.iostate = POLLERR|POLLIN | |
179 | self.ioloop.add_handler(self.socket, self._handle_events, |
|
193 | self.ioloop.add_handler(self.socket, self._handle_events, | |
180 | self.iostate) |
|
194 | self.iostate) | |
181 |
self. |
|
195 | self._run_loop() | |
182 |
|
196 | |||
183 | def stop(self): |
|
197 | def stop(self): | |
184 | self.ioloop.stop() |
|
198 | self.ioloop.stop() | |
@@ -385,7 +399,7 b' class SubSocketChannel(ZmqSocketChannel):' | |||||
385 | self.iostate = POLLIN|POLLERR |
|
399 | self.iostate = POLLIN|POLLERR | |
386 | self.ioloop.add_handler(self.socket, self._handle_events, |
|
400 | self.ioloop.add_handler(self.socket, self._handle_events, | |
387 | self.iostate) |
|
401 | self.iostate) | |
388 |
self. |
|
402 | self._run_loop() | |
389 |
|
403 | |||
390 | def stop(self): |
|
404 | def stop(self): | |
391 | self.ioloop.stop() |
|
405 | self.ioloop.stop() | |
@@ -473,7 +487,7 b' class RepSocketChannel(ZmqSocketChannel):' | |||||
473 | self.iostate = POLLERR|POLLIN |
|
487 | self.iostate = POLLERR|POLLIN | |
474 | self.ioloop.add_handler(self.socket, self._handle_events, |
|
488 | self.ioloop.add_handler(self.socket, self._handle_events, | |
475 | self.iostate) |
|
489 | self.iostate) | |
476 |
self. |
|
490 | self._run_loop() | |
477 |
|
491 | |||
478 | def stop(self): |
|
492 | def stop(self): | |
479 | self.ioloop.stop() |
|
493 | self.ioloop.stop() | |
@@ -591,7 +605,16 b' class HBSocketChannel(ZmqSocketChannel):' | |||||
591 | # returns quickly. Note: poll timeout is in |
|
605 | # returns quickly. Note: poll timeout is in | |
592 | # milliseconds. |
|
606 | # milliseconds. | |
593 | if until_dead > 0.0: |
|
607 | if until_dead > 0.0: | |
594 |
|
|
608 | while True: | |
|
609 | try: | |||
|
610 | self.poller.poll(1000 * until_dead) | |||
|
611 | except zmq.ZMQError as e: | |||
|
612 | if e.errno == errno.EINTR: | |||
|
613 | continue | |||
|
614 | else: | |||
|
615 | raise | |||
|
616 | else: | |||
|
617 | break | |||
595 |
|
618 | |||
596 | since_last_heartbeat = time.time()-request_time |
|
619 | since_last_heartbeat = time.time()-request_time | |
597 | if since_last_heartbeat > self.time_to_dead: |
|
620 | if since_last_heartbeat > self.time_to_dead: |
General Comments 0
You need to be logged in to leave comments.
Login now