| 178 | _exception(obj) |
| 179 | |
| 180 | def poll2(timeout=0.0, map=None): |
| 181 | # Use the poll() support added to the select module in Python 2.0 |
| 182 | if map is None: |
| 183 | map = socket_map |
| 184 | if timeout is not None: |
| 185 | # timeout is in milliseconds |
| 186 | timeout = int(timeout*1000) |
| 187 | pollster = select.poll() |
| 188 | if map: |
| 189 | for fd, obj in list(map.items()): |
| 190 | flags = 0 |
| 191 | if obj.readable(): |
| 192 | flags |= select.POLLIN | select.POLLPRI |
| 193 | # accepting sockets should not be writable |
| 194 | if obj.writable() and not obj.accepting: |
| 195 | flags |= select.POLLOUT |
| 196 | if flags: |
| 197 | pollster.register(fd, flags) |
| 198 | |
| 199 | r = pollster.poll(timeout) |
| 200 | for fd, flags in r: |
| 201 | obj = map.get(fd) |
| 202 | if obj is None: |
| 203 | continue |
| 204 | readwrite(obj, flags) |
| 205 | |
| 206 | poll3 = poll2 # Alias for backward compatibility |
| 207 | |