sending more than1000 requests per second in python
Question: I am trying to send requests concurrently to a server and then record the
average latency using this code:

    
    
    import Queue
    import time
    import threading
    import urllib2
    
    data = "{"image_1":"abc/xyz.jpg"}"
    headers = {.....}
    def get_url(q, url):
        num = 1
        sum = 0
        while num <= 200:
            start = time.time()
            req = urllib2.Request(url, data, headers)
            response = urllib2.urlopen(req)
            end = time.time()
            print end - start
            num = num + 1
            q.put(response.read())
            sum = sum + (end - start)
        print sum
    
    
    theurls = ["http://example.com/example"]
    q = Queue.Queue()
    
    for u in theurls:
        t = threading.Thread(target = get_url, args = (q, u))
        t.daemon = True
        t.start()
    
    while True:
        s = q.get()
        print s
    

This code is working just fine, but now I intend to send more than 1000
requests per second. I came across [this
answer](http://stackoverflow.com/a/32029760/5080347) but I am not sure how do
I use `grequests` for my case. Some insights will be very helpful.

Thanks


Answer: With qrequests you do not need to implement threading or queues. Grequests
handles that all for you. Just do a normal request but use grequests instead
like shown in the example.

