(self, timeout=None)
| 556 | return key |
| 557 | |
| 558 | def select(self, timeout=None): |
| 559 | timeout = None if timeout is None else max(timeout, 0) |
| 560 | # If max_ev is 0, kqueue will ignore the timeout. For consistent |
| 561 | # behavior with the other selector classes, we prevent that here |
| 562 | # (using max). See https://bugs.python.org/issue29255 |
| 563 | max_ev = self._max_events or 1 |
| 564 | ready = [] |
| 565 | try: |
| 566 | kev_list = self._selector.control(None, max_ev, timeout) |
| 567 | except InterruptedError: |
| 568 | return ready |
| 569 | for kev in kev_list: |
| 570 | fd = kev.ident |
| 571 | flag = kev.filter |
| 572 | events = 0 |
| 573 | if flag == select.KQ_FILTER_READ: |
| 574 | events |= EVENT_READ |
| 575 | if flag == select.KQ_FILTER_WRITE: |
| 576 | events |= EVENT_WRITE |
| 577 | |
| 578 | key = self._key_from_fd(fd) |
| 579 | if key: |
| 580 | ready.append((key, events & key.events)) |
| 581 | return ready |
| 582 | |
| 583 | def close(self): |
| 584 | self._selector.close() |
nothing calls this directly
no test coverage detected