| 167 | _exception(obj) |
| 168 | |
| 169 | def poll2(timeout=0.0, map=None): |
| 170 | # Use the poll() support added to the select module in Python 2.0 |
| 171 | if map is None: |
| 172 | map = socket_map |
| 173 | if timeout is not None: |
| 174 | # timeout is in milliseconds |
| 175 | timeout = int(timeout*1000) |
| 176 | pollster = select.poll() |
| 177 | if map: |
| 178 | for fd, obj in list(map.items()): |
| 179 | flags = 0 |
| 180 | if obj.readable(): |
| 181 | flags |= select.POLLIN | select.POLLPRI |
| 182 | # accepting sockets should not be writable |
| 183 | if obj.writable() and not obj.accepting: |
| 184 | flags |= select.POLLOUT |
| 185 | if flags: |
| 186 | pollster.register(fd, flags) |
| 187 | |
| 188 | r = pollster.poll(timeout) |
| 189 | for fd, flags in r: |
| 190 | obj = map.get(fd) |
| 191 | if obj is None: |
| 192 | continue |
| 193 | readwrite(obj, flags) |
| 194 | |
| 195 | poll3 = poll2 # Alias for backward compatibility |
| 196 | |