(self, timeout=None)
| 400 | return key |
| 401 | |
| 402 | def select(self, timeout=None): |
| 403 | # This is shared between poll() and epoll(). |
| 404 | # epoll() has a different signature and handling of timeout parameter. |
| 405 | if timeout is None: |
| 406 | timeout = None |
| 407 | elif timeout <= 0: |
| 408 | timeout = 0 |
| 409 | else: |
| 410 | # poll() has a resolution of 1 millisecond, round away from |
| 411 | # zero to wait *at least* timeout seconds. |
| 412 | timeout = math.ceil(timeout * 1e3) |
| 413 | ready = [] |
| 414 | try: |
| 415 | fd_event_list = self._selector.poll(timeout) |
| 416 | except InterruptedError: |
| 417 | return ready |
| 418 | for fd, event in fd_event_list: |
| 419 | events = 0 |
| 420 | if event & ~self._EVENT_READ: |
| 421 | events |= EVENT_WRITE |
| 422 | if event & ~self._EVENT_WRITE: |
| 423 | events |= EVENT_READ |
| 424 | |
| 425 | key = self._key_from_fd(fd) |
| 426 | if key: |
| 427 | ready.append((key, events & key.events)) |
| 428 | return ready |
| 429 | |
| 430 | |
| 431 | if hasattr(select, 'poll'): |
nothing calls this directly
no test coverage detected