[Zodb-checkins] CVS: ZODB3/ZEO/tests - zeoserver.py:1.8
Barry Warsaw
barry@wooz.org
Tue, 7 Jan 2003 17:21:45 -0500
Update of /cvs-repository/ZODB3/ZEO/tests
In directory cvs.zope.org:/tmp/cvs-serv29319
Modified Files:
zeoserver.py
Log Message:
Create a little Suicide thread so that if the parent process exits
(i.e. via ctrl-C) before it has a chance to make the killer connect,
these zeoserver processes will eventually go away (and clean up their
temp files).
=== ZODB3/ZEO/tests/zeoserver.py 1.7 => 1.8 ===
--- ZODB3/ZEO/tests/zeoserver.py:1.7 Tue Jan 7 17:12:58 2003
+++ ZODB3/ZEO/tests/zeoserver.py Tue Jan 7 17:21:43 2003
@@ -15,11 +15,13 @@
import os
import sys
+import time
import errno
import getopt
import random
import socket
import asyncore
+import threading
import ThreadedAsync.LoopCallback
import ZConfig.Context
@@ -108,6 +110,18 @@
self._count -= 1
+class Suicide(threading.Thread):
+ def __init__(self, addr):
+ threading.Thread.__init__(self)
+ self._adminaddr = addr
+
+ def run(self):
+ # If this process doesn't exit in 60 seconds, commit suicide
+ time.sleep(60)
+ from ZEO.tests.forker import shutdown_zeo_server
+ shutdown_zeo_server(self._adminaddr)
+
+
def main():
label = 'zeoserver:%d' % os.getpid()
log(label, 'starting')
@@ -140,9 +154,10 @@
# The rest of the args are hostname, portnum
zeo_port = int(args[0])
test_port = zeo_port + 1
+ test_addr = ('', test_port)
try:
log(label, 'creating the test server, ro: %s, keep: %s', ro_svr, keep)
- t = ZEOTestServer(('', test_port), storage, keep)
+ t = ZEOTestServer(test_addr, storage, keep)
except socket.error, e:
if e[0] <> errno.EADDRINUSE: raise
log(label, 'addr in use, closing and exiting')
@@ -155,6 +170,11 @@
addr, {'1': storage}, ro_svr,
invalidation_queue_size=invalidation_queue_size,
transaction_timeout=transaction_timeout)
+ # Create daemon suicide thread
+ d = Suicide(test_addr)
+ d.setDaemon(1)
+ d.start()
+ # Loop for socket events
log(label, 'entering ThreadedAsync loop')
ThreadedAsync.LoopCallback.loop()