erequests 0.4.0 released!

A new version of ERequests, the library that makes it easy to use Requests and Eventlet has just been released!

The API has been overhauled in order to provide 2 different ways of doing things:

  • A synchronous API, which will spawn a green thread and wait for it for every request sent this way
  • An asynchronous API, which just prepares the requests, allowing the user to throttle them with map or imap

Another important improvement is that when sending requests with map/imap, if one of them fails with an error, the exception object is returned, instead of raising it and stopping the process in the middle.

Here is an example script showing both APIs:

import erequests
urls = [
'http://www.heroku.com',
'http://tablib.org',
'http://httpbin.org',
'http://python-requests.org',
'http://kennethreitz.com'
]
# sync API (spawns a new green thread and waits for it)
for url in urls:
print erequests.get(url)
# async API (prepares the requests, they are sent with map/imap)
reqs = [erequests.async.get(url) for url in urls]
print list(erequests.imap(reqs))
view raw t.py hosted with ❤ by GitHub

Last but not least, I’d like to thank Juan Riaza for his help in designing the API and adapting the tests. šŸ™‚

You can install erequests easily from PyPI:

pip install erequests

Enjoy!

:wq

Leave a Reply