[Neo-report] r1994 gregory - /trunk/neo/connection.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Apr 1 17:31:56 CEST 2010
Author: gregory
Date: Thu Apr 1 17:31:53 2010
New Revision: 1994
Log:
Handler switcher may have to switch more than on handler at time.
Typical case:
- Handler H1 is set
- Send request R1
- Request switch to handler H2 (delayed)
- Request switch to handler H3 (delayed)
- Receive answer A1
- H2 must be discarded and H3 applied on the connection
Modified:
trunk/neo/connection.py
Modified: trunk/neo/connection.py
==============================================================================
--- trunk/neo/connection.py [iso-8859-1] (original)
+++ trunk/neo/connection.py [iso-8859-1] Thu Apr 1 17:31:53 2010
@@ -108,16 +108,16 @@
klass = request_dict.pop(msg_id, None)
if klass and isinstance(packet, klass) or packet.isError():
handler.packetReceived(self._connection, packet)
- # apply a pending handler if no more answers are pending
- if len(self._pending) > 1 and not request_dict:
- del self._pending[0]
- logging.debug('Apply handler %r', self._pending[0][1])
else:
logging.error('Unexpected answer: %r', packet)
notification = Packets.Notify('Unexpected answer: %r' % packet)
self._connection.notify(notification)
self._connection.abort()
handler.peerBroken(self._connection)
+ # apply a pending handler if no more answers are pending
+ while len(self._pending) > 1 and not self._pending[0][0]:
+ del self._pending[0]
+ logging.debug('Apply handler %r', self._pending[0][1])
def setHandler(self, handler):
if len(self._pending) == 1 and not self._pending[0][0]:
More information about the Neo-report
mailing list