import threading import httplib import time import sys if len(sys.argv) != 4: sys.exit("Must provide 3 args") theVar = 1 LOCAL=sys.argv[1] REMOTE=sys.argv[2] THREAD=int(sys.argv[3]) PORT = 8080 LOCALAPPSERVER=LOCAL+':'+str(PORT) REMOTEAPPSERVER=REMOTE+':'+str(PORT) print 'THe value of host is ',REMOTEAPPSERVER class MyThread ( threading.Thread ): def run ( self ): global theVar conn=httplib.HTTPConnection(LOCALAPPSERVER) try: t1 = time.clock() conn.request("GET", "/localApp/async?REMOTEAPPSEVER") r1=conn.getresponse() data=r1.read() t2 = time.clock() print 'Response '+ str( theVar ) + ' is ', r1.status, r1.reason, t2-t1 except: print 'Failed to make a connection to the host' theVar = theVar + 1 conn.close() time.sleep(0.2) t1 = time.clock() for x in xrange ( THREAD ): MyThread().start() t2 = time.clock() print 'Total response is ' + str(t2-t1)