File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -107,11 +107,14 @@ def poll(timeout=0.0, map=None):
107107 if map :
108108 r = []; w = []; e = []
109109 for fd , obj in map .items ():
110- e .append (fd )
111- if obj .readable ():
110+ is_r = obj .readable ()
111+ is_w = obj .writable ()
112+ if is_r :
112113 r .append (fd )
113- if obj . writable () :
114+ if is_w :
114115 w .append (fd )
116+ if is_r or is_w :
117+ e .append (fd )
115118 if [] == r == w == e :
116119 time .sleep (timeout )
117120 else :
@@ -151,12 +154,15 @@ def poll2(timeout=0.0, map=None):
151154 pollster = select .poll ()
152155 if map :
153156 for fd , obj in map .items ():
154- flags = select . POLLERR | select . POLLHUP | select . POLLNVAL
157+ flags = 0
155158 if obj .readable ():
156159 flags |= select .POLLIN | select .POLLPRI
157160 if obj .writable ():
158161 flags |= select .POLLOUT
159162 if flags :
163+ # Only check for exceptions if object was either readable
164+ # or writable.
165+ flags |= select .POLLERR | select .POLLHUP | select .POLLNVAL
160166 pollster .register (fd , flags )
161167 try :
162168 r = pollster .poll (timeout )
You can’t perform that action at this time.
0 commit comments