[Checkins] SVN: Sandbox/J1m/resumelb/src/zc/resumelb/lb. Deal with disconnecting clients by ignoring messages from workers with

Jim Fulton jim at zope.com
Sun Mar 4 20:44:14 UTC 2012


Log message for revision 124507:
  Deal with disconnecting clients by ignoring messages from workers with
  invalid request numbers.
  

Changed:
  U   Sandbox/J1m/resumelb/src/zc/resumelb/lb.py
  U   Sandbox/J1m/resumelb/src/zc/resumelb/lb.test

-=-
Modified: Sandbox/J1m/resumelb/src/zc/resumelb/lb.py
===================================================================
--- Sandbox/J1m/resumelb/src/zc/resumelb/lb.py	2012-03-04 20:21:20 UTC (rev 124506)
+++ Sandbox/J1m/resumelb/src/zc/resumelb/lb.py	2012-03-04 20:44:13 UTC (rev 124507)
@@ -263,7 +263,12 @@
             if rno == 0:
                 pool.new_resume(self, data)
             else:
-                readers[rno](data)
+                try:
+                    reader = readers[rno]
+                except KeyError:
+                    pass
+                else:
+                    reader(data)
 
     def __repr__(self):
         return self.__name__

Modified: Sandbox/J1m/resumelb/src/zc/resumelb/lb.test
===================================================================
--- Sandbox/J1m/resumelb/src/zc/resumelb/lb.test	2012-03-04 20:21:20 UTC (rev 124506)
+++ Sandbox/J1m/resumelb/src/zc/resumelb/lb.test	2012-03-04 20:44:13 UTC (rev 124507)
@@ -197,6 +197,18 @@
     >>> g2.value.status, g2.value.body == '2'*10000
     ('200 OK', True)
 
+Disconnecting clients
+=====================
+
+Sometimes, a client will disconnect after a request starts, but before
+the worker has sent the result.  When this happens, the lb will get a
+message from a worker for a request number that isn't active.  We'll
+emulate this by sending a message with a bogus message #, and verify
+that nothing is broken:
+
+    >>> write_message(worker2, 99, '')
+    >>> gevent.sleep(.01)
+
 Pool Management
 ===============
 
@@ -398,6 +410,8 @@
 Typically, by the time we remove an address, the worker will already
 have gone away.
 
+----------------------------------------------------------
+
 Cleanup:
 
     >>> lb.stop()



More information about the checkins mailing list