| 589 | |
| 590 | |
| 591 | def runonce(handlers, mux): |
| 592 | r = [] |
| 593 | w = [] |
| 594 | x = [] |
| 595 | to_remove = [s for s in handlers if not s.ok] |
| 596 | for h in to_remove: |
| 597 | handlers.remove(h) |
| 598 | |
| 599 | for s in handlers: |
| 600 | s.pre_select(r, w, x) |
| 601 | debug2('Waiting: %d r=%r w=%r x=%r (fullness=%d/%d)' |
| 602 | % (len(handlers), _fds(r), _fds(w), _fds(x), |
| 603 | mux.fullness, mux.too_full)) |
| 604 | (r, w, x) = select.select(r, w, x) |
| 605 | debug2(' Ready: %d r=%r w=%r x=%r' |
| 606 | % (len(handlers), _fds(r), _fds(w), _fds(x))) |
| 607 | ready = r + w + x |
| 608 | did = {} |
| 609 | for h in handlers: |
| 610 | for s in h.socks: |
| 611 | if s in ready: |
| 612 | h.callback(s) |
| 613 | did[s] = 1 |
| 614 | for s in ready: |
| 615 | if s not in did: |
| 616 | raise Fatal('socket %r was not used by any handler' % s) |