Adding progress feedback in Grequests task
Question: I've followed the grequests [usage
example](https://github.com/kennethreitz/grequests), but I'm trying to add
some progress feedback. A percentage of the completed requests. How could I
achieve that?

    
    
    import grequests
    
    urls = [
        'http://www.heroku.com',
        'http://python-tablib.org',
        'http://httpbin.org',
        'http://python-requests.org',
        'http://kennethreitz.com'
    ]
    
    def feedback(r, **kwargs):
                print "%s fetched." % r.url
                return r
    
    rs = (grequests.get(u, callback=feedback) for u in urls)
    res = grequests.map(rs)
    


Answer: Try this:

    
    
    from gevent import monkey
    monkey.patch_all()
    import gevent
    import sys
    import requests
    
    rs = [gevent.spawn(requests.get, u) for u in urls]
    [i.start() for i in rs]
    while 1:
        gevent.sleep()
        percent = 0.0
        for i in rs:
            if i.successful():
                percent += 100 / len(rs)
        sys.stdout.write(('='*int(percent))+(''*(100-int(percent)))+("\r [ %d"%percent+"% ] "))
        sys.stdout.flush()
        if percent == 100:
            sys.stdout.write('\n')
            sys.stdout.flush()
            break
    

