(self)
| 191 | self._stopping = True |
| 192 | |
| 193 | def run(self): |
| 194 | events = [] |
| 195 | while not self._stopping: |
| 196 | asap = False |
| 197 | try: |
| 198 | events = self.poll(TIMEOUT_PRECISION) |
| 199 | except (OSError, IOError) as e: |
| 200 | if errno_from_exception(e) in (errno.EPIPE, errno.EINTR): |
| 201 | # EPIPE: Happens when the client closes the connection |
| 202 | # EINTR: Happens when received a signal |
| 203 | # handles them as soon as possible |
| 204 | asap = True |
| 205 | logging.debug('poll:%s', e) |
| 206 | else: |
| 207 | logging.error('poll:%s', e) |
| 208 | traceback.print_exc() |
| 209 | continue |
| 210 | |
| 211 | for sock, fd, event in events: |
| 212 | handler = self._fdmap.get(fd, None) |
| 213 | if handler is not None: |
| 214 | handler = handler[1] |
| 215 | try: |
| 216 | handler.handle_event(sock, fd, event) |
| 217 | except (OSError, IOError) as e: |
| 218 | shell.print_exception(e) |
| 219 | now = time.time() |
| 220 | if asap or now - self._last_time >= TIMEOUT_PRECISION: |
| 221 | for callback in self._periodic_callbacks: |
| 222 | callback() |
| 223 | self._last_time = now |
| 224 | |
| 225 | def __del__(self): |
| 226 | self._impl.close() |
no test coverage detected