extras-buildsys/common XMLRPCServerProxy.py,1.5.4.2,1.5.4.3

Daniel Williams (dcbw) fedora-extras-commits at redhat.com
Thu Dec 1 04:18:57 UTC 2005


Author: dcbw

Update of /cvs/fedora/extras-buildsys/common
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv23292/common

Modified Files:
      Tag: STABLE_0_4
	XMLRPCServerProxy.py 
Log Message:
More test fixups


Index: XMLRPCServerProxy.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/common/XMLRPCServerProxy.py,v
retrieving revision 1.5.4.2
retrieving revision 1.5.4.3
diff -u -r1.5.4.2 -r1.5.4.3
--- XMLRPCServerProxy.py	1 Dec 2005 03:16:43 -0000	1.5.4.2
+++ XMLRPCServerProxy.py	1 Dec 2005 04:18:55 -0000	1.5.4.3
@@ -58,10 +58,14 @@
 import threading
 import time
 import random
+import OpenSSL
+import socket
 
 client_start = False
 
-_lock = threading.Lock()
+threadlist_lock = threading.Lock()
+threadlist = {}
+timed_out = 0
 
 class TestClient(threading.Thread):
     def __init__(self, certs, num):
@@ -74,12 +78,22 @@
             time.sleep(0.05)
         i = 0
         while i < 5:
-#            _lock.acquire()
-            reply = self.server.ping(self.num, i)
+            reply = None
+            try:
+                reply = self.server.ping(self.num, i)
+            except OpenSSL.SSL.Error, e:
+                reply = "OpenSSL Error (%s)" % e
+            except socket.timeout, e:
+                reply = "Socket timeout (%s)" % e
+                threadlist_lock.acquire()
+                timed_out = timed_out + 1
+                threadlist_lock.release()
             print "TRY(%d / %d): %s" % (self.num, i, reply)
             time.sleep(0.05)
-#            _lock.release()
             i = i + 1
+        threadlist_lock.acquire()
+        del threadlist[self]
+        threadlist_lock.release()
 
 
 if __name__ == '__main__':
@@ -95,6 +109,7 @@
     i = 100
     while i > 0:
         t = TestClient(certs, i)
+        threadlist[t] = None
         print "Created thread %d." % i
         t.start()
         i = i - 1
@@ -105,6 +120,11 @@
     while True:
         try:
             time.sleep(0.25)
+            threadlist_lock.acquire()
+            if len(threadlist) == 0:
+                break
+            threadlist_lock.release()
         except KeyboardInterrupt:
             os._exit(0)
+    print "All done. (%d timed out)" % timed_out
 




More information about the scm-commits mailing list