| 107 | self.consumer.consume() |
| 108 | |
| 109 | def loop(self, c): |
| 110 | resets = [self._resets] |
| 111 | shutdown = self._node_shutdown = threading.Event() |
| 112 | stopped = self._node_stopped = threading.Event() |
| 113 | try: |
| 114 | with c.connection_for_read() as connection: |
| 115 | info('pidbox: Connected to %s.', connection.as_uri()) |
| 116 | self._do_reset(c, connection) |
| 117 | while not shutdown.is_set() and c.connection: |
| 118 | if resets[0] < self._resets: |
| 119 | resets[0] += 1 |
| 120 | self._do_reset(c, connection) |
| 121 | try: |
| 122 | connection.drain_events(timeout=1.0) |
| 123 | except socket.timeout: |
| 124 | pass |
| 125 | finally: |
| 126 | stopped.set() |