[Zodb-checkins] SVN: ZODB/trunk/src/ZEO/zrpc/smac.py Added a should_close method that allows connection closes to be

Jim Fulton jim at zope.com
Fri May 11 16:04:10 EDT 2007


Log message for revision 75687:
  Added a should_close method that allows connection closes to be
  queued.
  

Changed:
  U   ZODB/trunk/src/ZEO/zrpc/smac.py

-=-
Modified: ZODB/trunk/src/ZEO/zrpc/smac.py
===================================================================
--- ZODB/trunk/src/ZEO/zrpc/smac.py	2007-05-11 20:04:00 UTC (rev 75686)
+++ ZODB/trunk/src/ZEO/zrpc/smac.py	2007-05-11 20:04:07 UTC (rev 75687)
@@ -68,6 +68,8 @@
 
 MAC_BIT = 0x80000000L
 
+_close_marker = object()
+
 class SizedMessageAsyncConnection(asyncore.dispatcher):
     __super_init = asyncore.dispatcher.__init__
     __super_close = asyncore.dispatcher.close
@@ -235,6 +237,9 @@
         else:
             return True
 
+    def should_close(self):
+        self.__output.append(_close_marker)
+
     def handle_write(self):
         self.__output_lock.acquire()
         try:
@@ -250,7 +255,13 @@
 
                 l = 0
                 for i in range(len(output)):
-                    l += len(output[i])
+                    try:
+                        l += len(output[i])
+                    except TypeError:
+                        # We had an output marker, close the connection
+                        assert output[i] is _close_marker
+                        return self.close()
+                    
                     if l > SEND_SIZE:
                         break
 



More information about the Zodb-checkins mailing list