Hi Dennis, Nice pseudo code! :-)
Is it possible benchmark/measure the latency of a HTTP connection for each threads by timing the duration of the requests.get method to complete?
I also plan to test with gevent.monkey extension for enabling cooperative multithreading support:
from gevent import monkey monkey.patch_all() Etienne Le 2018-02-15 à 11:56, Dennis Lee Bieber a écrit :
Keyword: threads Create a number of threads, each handling one request, and use a global flag to start them. And maybe a queue to retrieve Pseudo-code (I haven't checked the manual for correct API): hold = True resultQ = Queue.Queue() def worker(ID): while hold: pass r = requests.get(...) resultQ.put( (ID, r.status_code) ) def benchmark(): requestTasks = [ threading.thread( worker, args=(ID) ) for ID in range(NUMBEROFREQUESTS) ] for rT in requestTasks.start() #or is it .run() #workers are now busy waiting for hold to False #better would be to use threading.Condition and .notifyAll() #having each thread wait on a global condition variable, #rather than spinning on a busy wait hold = False for _ in range(NUMBEROFREQUESTS): (ID, code) = resultQ.get() requestTasks[ID].join() #put any asserts here
-- Etienne Robillard tkad...@yandex.com https://www.isotopesoftware.ca/ -- https://mail.python.org/mailman/listinfo/python-list