Home:ALL Converter>Is it possible to make grequests and requests_cache work together?

Is it possible to make grequests and requests_cache work together?

Ask Time:2014-03-14T21:47:24         Author:mnowotka

Json Formatter

Look at this code:

import requests
import grequests
import requests_cache
requests_cache.install_cache('bla')

urls = [
    'http://www.heroku.com',
    'http://python-tablib.org',
    'http://httpbin.org',
    'http://python-requests.org',
    'http://kennethreitz.com'
]

rs = (grequests.get(u) for u in urls)
results = grequests.map(rs)

I would expect that after executing this I will find bla.sqlite file in the current directory and executing

results = grequests.map(rs)

will be MUCH faster because data will be taken from sqlite cache. Unfortunately this is not true, file wasn't created at all and there is no speedup. When I use requests insetead of grequests everything works fine. So the question is a title says: Is it possible to make grequests and requests_cache work together? and if yes, how?

Author:mnowotka,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/22406830/is-it-possible-to-make-grequests-and-requests-cache-work-together
yy