[Zodb-checkins] SVN: ZODB/branches/jim-thready-zeo2/src/ZEO/zrpc/connection.py Run a separate asyncore thread in the server for each client.
Jim Fulton
jim at zope.com
Thu Sep 17 14:09:53 EDT 2009
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__
More information about the Zodb-checkins
mailing list