[Zodb-checkins] CVS: StandaloneZODB/ZEO - StorageServer.py:1.21.4.20
Jeremy Hylton
jeremy@zope.com
Thu, 10 Jan 2002 19:17:19 -0500
Update of /cvs-repository/StandaloneZODB/ZEO
In directory cvs.zope.org:/tmp/cvs-serv22354
Modified Files:
Tag: ZEO-ZRPC-Dev
StorageServer.py
Log Message:
Improve close() so that it really shuts the servers down.
Also some misc cleanup:
No need to assert self._transaction is None, because it's assigned to
just two lines above.
Replace map + lambda with list comprehension. ZEO 2 will only work
with Zope 2.5.
=== StandaloneZODB/ZEO/StorageServer.py 1.21.4.19 => 1.21.4.20 ===
"""
+import asyncore
import cPickle
import os
import sys
@@ -158,7 +159,21 @@
p.client.info(info)
def close_server(self):
+ # Close the dispatcher so that there are no new connections.
self.dispatcher.close()
+ for conn_list in self.connections.values():
+ for c in conn_list:
+ c.close()
+ for storage in self.storages.values():
+ storage.close()
+ # Force the asyncore mainloop to exit by hackery, i.e. close
+ # every socket in the map. loop() will return when the map is
+ # empty.
+ for s in asyncore.socket_map.values():
+ try:
+ s.close()
+ except:
+ pass
def close(self, conn):
# XXX who calls this?
@@ -279,7 +294,6 @@
p, os, v, pv, osv = self.zeoLoad(oid)
except: # except what?
return None
- p = pv = None # free the pickles
if os != s:
self.client.invalidate((oid, ''))
elif osv != sv:
@@ -427,7 +441,6 @@
if not self._handle_waiting():
self._transaction = None
self.__invalidated = []
- assert self._transaction is None
def tpc_abort(self, id):
if not self._check_tid(id):
@@ -438,7 +451,6 @@
if not self._handle_waiting():
self._transaction = None
self.__invalidated = []
- assert self._transaction is None
def _restart_delayed_transaction(self, delay, trans):
self._transaction = trans
@@ -458,7 +470,7 @@
"""Return a sequence of n new oids, where n defaults to 100"""
if n < 0:
n = 1
- return map(lambda x, self=self: self.__storage.new_oid(), range(n))
+ return [self.__storage.new_oid() for i in range(n)]
def fixup_storage(storage):
# backwards compatibility hack