Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?


Failed to load latest commit information.

GRequests: Asynchronous Requests

GRequests allows you to use Requests with Gevent to make asynchronous HTTP Requests easily.

version pyversions

Note: You should probably use requests-threads or requests-futures instead.


Installation is easy with pip:

$ pip install grequests


Usage is simple:

import grequests

urls = [

Create a set of unsent Requests:

>>> rs = (grequests.get(u) for u in urls)

Send them all at the same time:

[<Response [200]>, <Response [200]>, <Response [200]>, <Response [200]>, None, <Response [200]>]

The HTTP verb methods in grequests (grequests.get,, etc) accept all the same keyword arguments as in the requests library.

To handle timeouts or any other exception during the connection of the request, you can add an optional exception handler that will be called with the request and exception inside the main thread:

>>> def exception_handler(request, exception):
...    print("Request failed")

>>> reqs = [
...    grequests.get('', timeout=0.001),
...    grequests.get('http://fakedomain/'),
...    grequests.get('')]
>>>, exception_handler=exception_handler)
Request failed
Request failed
[None, None, <Response [500]>]

For some speed/performance gains, you may also want to use imap instead of map. imap returns a generator of responses. Order of these responses does not map to the order of the requests you send out. The API for imap is equivalent to the API for map. You can also adjust the size argument to map or imap to increase the gevent pool size.

for resp in grequests.imap(reqs, size=10):

NOTE: because grequests leverages gevent (which in turn uses monkeypatching for enabling concurrency), you will often need to make sure grequests is imported before other libraries, especially requests, to avoid problems. See grequests gevent issues for additional information.

import grequests
import requests

import requests
import grequests