[Zodb-checkins] CVS: StandaloneZODB/ZEO - StorageServer.py:1.28.2.2
Jeremy Hylton
jeremy@zope.com
Wed, 8 Aug 2001 13:31:38 -0400
Update of /cvs-repository/StandaloneZODB/ZEO
In directory cvs.zope.org:/tmp/cvs-serv27064
Modified Files:
Tag: zeo-1_0-branch
StorageServer.py
Log Message:
Avoid long delays at the end of a pack.
When a client calls pack, a separate thread is started to call the
pack call on the storage. When the thread finishes, it calls
message_output() to send a response to the client. If asyncore is
currently in a poll call when this happens, the output won't be
detected until the next poll call. If there is little I/O on the
connection, this won't happen until the select call times out after 30
seconds.
The trigger is the standard gimmick for one thread to notify a
mainloop in another thread that the first thread has some I/O to do.
It exits the current select. The next poll call detects that the
triggering thread is ready to do I/O and handles it.
=== StandaloneZODB/ZEO/StorageServer.py 1.28.2.1 => 1.28.2.2 ===
from ZODB.Transaction import Transaction
import traceback
-from zLOG import LOG, INFO, ERROR, TRACE
+from zLOG import LOG, INFO, ERROR, TRACE, BLATHER
from ZODB.referencesf import referencesf
from thread import start_new_thread
from cStringIO import StringIO
+from ZEO import trigger
class StorageServerError(POSException.StorageError): pass
@@ -124,7 +125,6 @@
self.__connections={}
self.__get_connections=self.__connections.get
-
asyncore.dispatcher.__init__(self)
if type(connection) is type(''):
@@ -234,6 +234,7 @@
self.__server=server
self.__invalidated=[]
self.__closed=None
+ self._pack_trigger = trigger.trigger()
if __debug__: debug='ZEO Server'
else: debug=0
SizedMessageAsyncConnection.__init__(self, sock, addr, debug=debug)
@@ -384,16 +385,21 @@
if wait: return _noreturn
def _pack(self, t, wait=0):
- try:
+ try:
+ LOG('ZEO Server', BLATHER, 'pack begin')
self.__storage.pack(t, referencesf)
+ LOG('ZEO Server', BLATHER, 'pack end')
except:
LOG('ZEO Server', ERROR,
'Pack failed for %s' % self.__storage_id,
error=sys.exc_info())
- if wait: self.return_error(sys.exc_info()[0], sys.exc_info()[1])
+ if wait:
+ self.return_error(sys.exc_info()[0], sys.exc_info()[1])
+ self._pack_trigger.pull_trigger()
else:
if wait:
self.message_output('RN.')
+ self._pack_trigger.pull_trigger()
else:
# Broadcast new size statistics
self.__server.invalidate(0, self.__storage_id, (),