diff options
author | Andrew M. Kuchling <amk@amk.ca> | 2004-09-01 14:04:51 (GMT) |
---|---|---|
committer | Andrew M. Kuchling <amk@amk.ca> | 2004-09-01 14:04:51 (GMT) |
commit | e47c381c62091d5d8583438b70632eecb96ad29e (patch) | |
tree | 30f66f19cb82f9311cc63361b5718d75f9a3fee8 /Lib | |
parent | 3b2cdad4fdd70129856eedb64676d239b86326ac (diff) | |
download | cpython-e47c381c62091d5d8583438b70632eecb96ad29e.zip cpython-e47c381c62091d5d8583438b70632eecb96ad29e.tar.gz cpython-e47c381c62091d5d8583438b70632eecb96ad29e.tar.bz2 |
[Bug #1011606] Only check file descriptors for exceptional conditions if the fd is readable or writable
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/asyncore.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Lib/asyncore.py b/Lib/asyncore.py index f63a83e..a2387a1 100644 --- a/Lib/asyncore.py +++ b/Lib/asyncore.py @@ -107,11 +107,14 @@ def poll(timeout=0.0, map=None): if map: r = []; w = []; e = [] for fd, obj in map.items(): - e.append(fd) - if obj.readable(): + is_r = obj.readable() + is_w = obj.writable() + if is_r: r.append(fd) - if obj.writable(): + if is_w: w.append(fd) + if is_r or is_w: + e.append(fd) if [] == r == w == e: time.sleep(timeout) else: @@ -151,12 +154,15 @@ def poll2(timeout=0.0, map=None): pollster = select.poll() if map: for fd, obj in map.items(): - flags = select.POLLERR | select.POLLHUP | select.POLLNVAL + flags = 0 if obj.readable(): flags |= select.POLLIN | select.POLLPRI if obj.writable(): flags |= select.POLLOUT if flags: + # Only check for exceptions if object was either readable + # or writable. + flags |= select.POLLERR | select.POLLHUP | select.POLLNVAL pollster.register(fd, flags) try: r = pollster.poll(timeout) |