[Python-checkins] python/dist/src/Lib asyncore.py,1.60,1.61

akuchling at users.sourceforge.net akuchling at users.sourceforge.net
Wed Sep 1 16:04:53 CEST 2004


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20591

Modified Files:
	asyncore.py 
Log Message:
[Bug #1011606] Only check file descriptors for exceptional conditions if the fd is readable or writable

Index: asyncore.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/asyncore.py,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -d -r1.60 -r1.61
--- asyncore.py	13 Aug 2004 20:06:57 -0000	1.60
+++ asyncore.py	1 Sep 2004 14:04:51 -0000	1.61
@@ -107,11 +107,14 @@
     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 @@
     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)



More information about the Python-checkins mailing list