[Zodb-checkins] CVS: StandaloneZODB/ZEO/tests - forker.py:1.1.2.7

Jeremy Hylton jeremy@zope.com
Mon, 7 Jan 2002 15:56:45 -0500


Update of /cvs-repository/StandaloneZODB/ZEO/tests
In directory cvs.zope.org:/tmp/cvs-serv10015/tests

Modified Files:
      Tag: ZEO-ZRPC-Dev
	forker.py 
Log Message:
Make the server shutdown more robust.

XXX Also break the profile option for versions  of Python earlier than
2.2 by using hotshot rather than profile.


=== StandaloneZODB/ZEO/tests/forker.py 1.1.2.6 => 1.1.2.7 ===
 import asyncore
 import os
-import profile
+import hotshot
 import random
 import socket
 import sys
@@ -76,9 +76,11 @@
             buf = self.recv(4)
             if buf:
                 assert buf == "done"
+                server.close_server()
                 asyncore.socket_map.clear()
 
         def handle_close(self):
+            server.close_server()
             asyncore.socket_map.clear()
 
     class ZEOClientExit:
@@ -99,10 +101,10 @@
         if pid == 0:
             try:
                 if PROFILE:
-                    p = profile.Profile()
-                    p.runctx("run_server(storage, addr, rd, wr)", globals(),
-                             locals())
-                    p.dump_stats("stats.s.%d" % os.getpid())
+                    p = hotshot.Profile("stats.s.%d" % os.getpid())
+                    p.runctx("run_server(storage, addr, rd, wr)",
+                             globals(), locals())
+                    p.close()
                 else:
                     run_server(storage, addr, rd, wr)
             except:
@@ -115,9 +117,10 @@
 
     def run_server(storage, addr, rd, wr):
         # in the child, run the storage server
+        global server
         os.close(wr)
         ZEOServerExit(rd)
-        serv = ZEO.StorageServer.StorageServer(addr, {'1':storage})
+        server = ZEO.StorageServer.StorageServer(addr, {'1':storage})
         asyncore.loop()
         os.close(rd)
         storage.close()