SVN: ZODB/branches/jim-thready-zeo2/src/ZEO/zrpc/connection.py Run a separate asyncore thread in the server for each client.

Jim Fulton <[email protected]>
Newsgroups gmane.comp.python.zope.zodb.cvs
Message-ID <[email protected]>
Log message for revision 104257:
  Run a separate asyncore thread in the server for each client.
  

Changed:
  U   ZODB/branches/jim-thready-zeo2/src/ZEO/zrpc/connection.py

-=-
Modified: ZODB/branches/jim-thready-zeo2/src/ZEO/zrpc/connection.py
===================================================================
--- ZODB/branches/jim-thready-zeo2/src/ZEO/zrpc/connection.py	2009-09-17 18:09:51 UTC (rev 104256)
+++ ZODB/branches/jim-thready-zeo2/src/ZEO/zrpc/connection.py	2009-09-17 18:09:52 UTC (rev 104257)
@@ -789,13 +789,19 @@
     unlogged_exception_types = (ZODB.POSException.POSKeyError, )
 
     # Servers use a shared server trigger that uses the asyncore socket map
-    trigger = trigger()
+    #trigger = trigger()
 
     def __init__(self, sock, addr, obj, mgr):
         self.mgr = mgr
-        Connection.__init__(self, sock, addr, obj, 'S')
+        map={}
+        Connection.__init__(self, sock, addr, obj, 'S', map=map)
         self.marshal = ServerMarshaller()
+        self.trigger = trigger(map)
 
+        thread = threading.Thread(target=server_loop, args=(map,))
+        thread.setDaemon(True)
+        thread.start()
+
     def handshake(self):
         # Send the server's preferred protocol to the client.
         self.message_output(self.current_protocol)
@@ -808,6 +814,12 @@
         self.obj.notifyDisconnected()
         Connection.close(self)
 
+def server_loop(map):
+    while len(map) > 1:
+        asyncore.poll(30.0, map)
+    for o in map.values():
+        o.close()
+
 class ManagedClientConnection(Connection):
     """Client-side Connection subclass."""
     __super_init = Connection.__init__
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.