Poll the registered 0MQ or native fds for I/O. If there are currently events ready to be processed, this function will return immediately. Otherwise, this function will return as soon the first event is available or after timeout milliseconds have elapsed. Parameter
(self, timeout: int | None = None)
| 78 | self._map[socket] -= 1 |
| 79 | |
| 80 | def poll(self, timeout: int | None = None) -> list[tuple[Any, int]]: |
| 81 | """Poll the registered 0MQ or native fds for I/O. |
| 82 | |
| 83 | If there are currently events ready to be processed, this function will return immediately. |
| 84 | Otherwise, this function will return as soon the first event is available or after timeout |
| 85 | milliseconds have elapsed. |
| 86 | |
| 87 | Parameters |
| 88 | ---------- |
| 89 | timeout : int |
| 90 | The timeout in milliseconds. If None, no `timeout` (infinite). This |
| 91 | is in milliseconds to be compatible with ``select.poll()``. |
| 92 | |
| 93 | Returns |
| 94 | ------- |
| 95 | events : list |
| 96 | The list of events that are ready to be processed. |
| 97 | This is a list of tuples of the form ``(socket, event_mask)``, where the 0MQ Socket |
| 98 | or integer fd is the first element, and the poll event mask (POLLIN, POLLOUT) is the second. |
| 99 | It is common to call ``events = dict(poller.poll())``, |
| 100 | which turns the list of tuples into a mapping of ``socket : event_mask``. |
| 101 | """ |
| 102 | if timeout is None or timeout < 0: |
| 103 | timeout = -1 |
| 104 | elif isinstance(timeout, float): |
| 105 | timeout = int(timeout) |
| 106 | return zmq_poll(self.sockets, timeout=timeout) |
| 107 | |
| 108 | |
| 109 | def select( |