Does poll on open connections, if available.
(self)
| 320 | return select.select(readable, writable, readable) + (True,) |
| 321 | |
| 322 | def _poll_select(self): |
| 323 | """Does poll on open connections, if available.""" |
| 324 | remaining = [] |
| 325 | |
| 326 | self.poll.register(self.socket.handle.fileno(), select.POLLIN | select.POLLRDNORM) |
| 327 | self.poll.register(self._read.fileno(), select.POLLIN | select.POLLRDNORM) |
| 328 | |
| 329 | for i, connection in list(self.clients.items()): |
| 330 | if connection.is_readable(): |
| 331 | self.poll.register(connection.fileno(), select.POLLIN | select.POLLRDNORM | select.POLLERR | select.POLLHUP | select.POLLNVAL) |
| 332 | if connection.remaining or connection.received: |
| 333 | remaining.append(connection.fileno()) |
| 334 | if connection.is_writeable(): |
| 335 | self.poll.register(connection.fileno(), select.POLLOUT | select.POLLWRNORM) |
| 336 | if connection.is_closed(): |
| 337 | try: |
| 338 | self.poll.unregister(i) |
| 339 | except KeyError: |
| 340 | logger.debug("KeyError in unregistering connections...") |
| 341 | del self.clients[i] |
| 342 | if remaining: |
| 343 | return remaining, [], [], False |
| 344 | |
| 345 | rlist = [] |
| 346 | wlist = [] |
| 347 | xlist = [] |
| 348 | pollres = self.poll.poll() |
| 349 | for fd, event in pollres: |
| 350 | if event & (select.POLLERR | select.POLLHUP | select.POLLNVAL): |
| 351 | xlist.append(fd) |
| 352 | elif event & (select.POLLOUT | select.POLLWRNORM): |
| 353 | wlist.append(fd) |
| 354 | elif event & (select.POLLIN | select.POLLRDNORM): |
| 355 | rlist.append(fd) |
| 356 | else: # should be impossible |
| 357 | logger.debug("reached an impossible state in _poll_select") |
| 358 | xlist.append(fd) |
| 359 | |
| 360 | return rlist, wlist, xlist, True |
| 361 | |
| 362 | def handle(self): |
| 363 | """Handle requests. |
no test coverage detected