[Zodb-checkins] CVS: Zope/lib/python/ZEO/tests - forker.py:1.37.6.2

Jeremy Hylton jeremy at zope.com
Wed Oct 8 11:41:30 EDT 2003


Update of /cvs-repository/Zope/lib/python/ZEO/tests
In directory cvs.zope.org:/tmp/cvs-serv14577

Modified Files:
      Tag: Zope-2_7-branch
	forker.py 
Log Message:
Try to make shutdown_zeo_server() more robust.


=== Zope/lib/python/ZEO/tests/forker.py 1.37.6.1 => 1.37.6.2 ===
--- Zope/lib/python/ZEO/tests/forker.py:1.37.6.1	Mon Sep 15 17:26:54 2003
+++ Zope/lib/python/ZEO/tests/forker.py	Wed Oct  8 11:41:29 2003
@@ -123,12 +123,23 @@
 
 
 def shutdown_zeo_server(adminaddr):
-    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-    s.connect(adminaddr)
-    try:
-        ack = s.recv(1024)
-    except socket.error, e:
-        if e[0] <> errno.ECONNRESET: raise
-        ack = 'no ack received'
-    zLOG.LOG('shutdownServer', zLOG.DEBUG, 'acked: %s' % ack)
-    s.close()
+    # Do this in a loop to guard against the possibility that the
+    # client failed to connect to the adminaddr earlier.  That really
+    # only requires two iterations, but do a third for pure
+    # superstition.
+    for i in range(3):
+        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+        try:
+            s.connect(adminaddr)
+        except socket.error, e:
+            if e[0] == errno.ECONNREFUSED and i > 0:
+                break
+            raise
+        try:
+            ack = s.recv(1024)
+        except socket.error, e:
+            if e[0] == errno.ECONNRESET:
+                raise
+            ack = 'no ack received'
+        zLOG.LOG('shutdownServer', zLOG.DEBUG, 'acked: %s' % ack)
+        s.close()




More information about the Zodb-checkins mailing list