[Neo-report] r2420 vincent - in /trunk/neo: connection.py event.py

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Nov 5 18:43:29 CET 2010


Author: vincent
Date: Fri Nov  5 18:43:28 2010
New Revision: 2420

Log:
Always call _poll after handling a packet.

This should increase process responsiveness when a single _poll call
fetched many packets: as long as packet queue is not empty, no epoll.poll
call was made. This means that outgoing packets were kept in our buffer
until packet queue becomes empty.

Modified:
    trunk/neo/connection.py
    trunk/neo/event.py

Modified: trunk/neo/connection.py
==============================================================================
--- trunk/neo/connection.py [iso-8859-1] (original)
+++ trunk/neo/connection.py [iso-8859-1] Fri Nov  5 18:43:28 2010
@@ -179,7 +179,10 @@ class HandlerSwitcher(object):
         else:
             neo.logging.error('Unexpected answer %r in %r', packet, connection)
             notification = Packets.Notify('Unexpected answer: %r' % packet)
-            connection.notify(notification)
+            try:
+                connection.notify(notification)
+            except ConnectorConnectionClosedException:
+                pass
             connection.abort()
             handler.peerBroken(connection)
         # apply a pending handler if no more answers are pending

Modified: trunk/neo/event.py
==============================================================================
--- trunk/neo/event.py [iso-8859-1] (original)
+++ trunk/neo/event.py [iso-8859-1] Fri Nov  5 18:43:28 2010
@@ -81,7 +81,9 @@ class EpollEventManager(object):
         return result
 
     def _addPendingConnection(self, conn):
-        self._pending_processing.append(conn)
+        pending_processing = self._pending_processing
+        if conn not in pending_processing:
+            pending_processing.append(conn)
 
     def poll(self, timeout=1):
         to_process = self._getPendingConnection()
@@ -102,6 +104,10 @@ class EpollEventManager(object):
                         self._addPendingConnection(to_process)
             finally:
                 to_process.unlock()
+            # Non-blocking call: as we handled a packet, we should just offer
+            # poll a chance to fetch & send already-available data, but it must
+            # not delay us.
+            self._poll(timeout=0)
 
     def _poll(self, timeout=1):
         rlist, wlist, elist = self.epoll.poll(timeout)





More information about the Neo-report mailing list