extras-buildsys/common XMLRPCServerProxy.py,1.8,1.9
Daniel Williams (dcbw)
fedora-extras-commits at redhat.com
Wed Feb 15 17:07:15 UTC 2006
Author: dcbw
Update of /cvs/fedora/extras-buildsys/common
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv12023/common
Modified Files:
XMLRPCServerProxy.py
Log Message:
2006-02-15 Dan Williams <dcbw at redhat.com>
* common/XMLRPCServerProxy.py
- Fix up some of the test code
Index: XMLRPCServerProxy.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/common/XMLRPCServerProxy.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- XMLRPCServerProxy.py 1 Dec 2005 04:18:24 -0000 1.8
+++ XMLRPCServerProxy.py 15 Feb 2006 17:07:07 -0000 1.9
@@ -65,12 +65,12 @@
threadlist_lock = threading.Lock()
threadlist = {}
-timed_out = 0
class TestClient(threading.Thread):
- def __init__(self, certs, num):
+ def __init__(self, certs, num, tm):
self.server = PlgXMLRPCServerProxy("https://127.0.0.1:8886", certs, timeout=20)
self.num = i
+ self.tm = tm
threading.Thread.__init__(self)
def run(self):
@@ -86,7 +86,7 @@
except socket.timeout, e:
reply = "Socket timeout (%s)" % e
threadlist_lock.acquire()
- timed_out = timed_out + 1
+ self.tm.inc()
threadlist_lock.release()
print "TRY(%d / %d): %s" % (self.num, i, reply)
time.sleep(0.05)
@@ -95,6 +95,18 @@
del threadlist[self]
threadlist_lock.release()
+class TimeoutCounter:
+ def __init__(self):
+ self._timedout = 0
+ self._lock = threading.Lock();
+
+ def inc(self):
+ self._lock.acquire()
+ self._timedout = self._timedout + 1
+ self._lock.release()
+
+ def get(self):
+ return self._timedout
if __name__ == '__main__':
if len(sys.argv) < 4:
@@ -106,9 +118,10 @@
certs['ca_cert'] = sys.argv[2]
certs['peer_ca_cert'] = sys.argv[3]
+ tm = TimeoutCounter()
i = 100
while i > 0:
- t = TestClient(certs, i)
+ t = TestClient(certs, i, tm)
threadlist[t] = None
print "Created thread %d." % i
t.start()
@@ -126,5 +139,5 @@
threadlist_lock.release()
except KeyboardInterrupt:
os._exit(0)
- print "All done. (%d timed out)" % timed_out
+ print "All done. (%d timed out)" % tm.get()
More information about the fedora-extras-commits
mailing list