[Zope-Checkins] CVS: ZODB3/ZEO/tests - forker.py:1.33 zeoserver.py:1.12
Jeremy Hylton
jeremy@zope.com
Mon, 27 Jan 2003 15:11:27 -0500
Update of /cvs-repository/ZODB3/ZEO/tests
In directory cvs.zope.org:/tmp/cvs-serv29894/ZEO/tests
Modified Files:
forker.py zeoserver.py
Log Message:
Backport changes from ZODB4.
Explicitly close sockets to make tests run faster.
=== ZODB3/ZEO/tests/forker.py 1.32 => 1.33 ===
--- ZODB3/ZEO/tests/forker.py:1.32 Thu Jan 9 18:57:21 2003
+++ ZODB3/ZEO/tests/forker.py Mon Jan 27 15:11:25 2003
@@ -91,17 +91,20 @@
pid = os.spawnve(os.P_NOWAIT, sys.executable, tuple(args), d)
adminaddr = ('localhost', port+1)
# We need to wait until the server starts, but not forever
- s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- for i in range(5):
+ for i in range(10):
+ time.sleep(0.25)
try:
zLOG.LOG('forker', zLOG.DEBUG, 'connect %s' % i)
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(adminaddr)
ack = s.recv(1024)
+ s.close()
zLOG.LOG('forker', zLOG.DEBUG, 'acked: %s' % ack)
break
except socket.error, e:
- if e[0] <> errno.ECONNREFUSED: raise
- time.sleep(1)
+ if e[0] not in (errno.ECONNREFUSED, errno.ECONNRESET):
+ raise
+ s.close()
else:
zLOG.LOG('forker', zLOG.DEBUG, 'boo hoo')
raise
=== ZODB3/ZEO/tests/zeoserver.py 1.11 => 1.12 ===
--- ZODB3/ZEO/tests/zeoserver.py:1.11 Thu Jan 9 18:57:21 2003
+++ ZODB3/ZEO/tests/zeoserver.py Mon Jan 27 15:11:25 2003
@@ -71,6 +71,7 @@
def __init__(self, addr, server, keep):
self.__super_init()
self._server = server
+ self._sockets = [self]
self._keep = keep
# Count down to zero, the number of connects
self._count = 1
@@ -105,11 +106,22 @@
for storage in self._server.storages.values():
cleanup(storage)
self.log('exiting')
+ # Close all the other sockets so that we don't have to wait
+ # for os._exit() to get to it before starting the next
+ # server process.
+ for s in self._sockets:
+ s.close()
+ # Now explicitly close the socket returned from accept(),
+ # since it didn't go through the wrapper.
+ sock.close()
os._exit(0)
self.log('continuing')
sock.send('X')
self._count -= 1
+ def register_socket(self, sock):
+ # Register a socket to be closed when server shutsdown.
+ self._sockets.append(sock)
class Suicide(threading.Thread):
def __init__(self, addr):
@@ -118,7 +130,8 @@
def run(self):
# If this process doesn't exit in 60 seconds, commit suicide
- time.sleep(60)
+ for i in range(20):
+ time.sleep(5)
from ZEO.tests.forker import shutdown_zeo_server
# XXX If the -k option was given to zeoserver, then the process will
# go away but the temp files won't get cleaned up.
@@ -177,6 +190,7 @@
storage.close()
cleanup(storage)
sys.exit(2)
+ t.register_socket(serv.dispatcher)
# Create daemon suicide thread
d = Suicide(test_addr)
d.setDaemon(1)