| 126 | def select(self, timeout: float) -> Tuple[List, List, List]: |
| 127 | |
| 128 | def select_inner(timeout): |
| 129 | # This inner select adds the writing fds to the exception fd set |
| 130 | # because Windows returns connected fds in the exception set not the |
| 131 | # writable set |
| 132 | r = self._reading |
| 133 | w = self._writing |
| 134 | |
| 135 | now = time.time() |
| 136 | |
| 137 | # No timeout or deadline |
| 138 | if timeout is None and self._deadline is None: |
| 139 | return IO.select(r, w, w) |
| 140 | |
| 141 | if timeout is None: |
| 142 | t = max(0, self._deadline - now) |
| 143 | return IO.select(r, w, w, t) |
| 144 | |
| 145 | if self._deadline is None: |
| 146 | return IO.select(r, w, w, timeout) |
| 147 | |
| 148 | t = max(0, min(timeout, self._deadline - now)) |
| 149 | if len(r) == 0 and len(w) == 0: |
| 150 | if t > 0: |
| 151 | IO.sleep(t) |
| 152 | return ([], [], []) |
| 153 | |
| 154 | return IO.select(r, w, w, t) |
| 155 | |
| 156 | # Need to allow for signals interrupting us on Python 2 |
| 157 | # In this case the signal handler could have messed up our internal state |