Closed jwkvam closed 6 years ago
I'm not sure I understand the issue and cannot reproduce. Without doing anything, it works fine in 3.6 for me.
It's a known issue that importing requests
before importing grequests
causes problems. Perhaps that is your issue. Have you tried reordering the imports?
Python 3.6.3 (v3.6.3:2c5fed86e0, Oct 3 2017, 00:32:08)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import grequests
In [2]: import requests
In [3]: from time import time
In [4]: urls = 20 * ['https://google.com']
...:
...: rs = (grequests.get(u) for u in urls)
...:
...: start = time()
...: res = grequests.map(rs)
...: stop = time()
...:
...: print(f'greqs {stop - start}')
...:
...: start = time()
...: rs = [requests.get(u) for u in urls]
...: stop = time()
...:
...: print(f'reqs {stop - start}')
...:
greqs 0.5951080322265625
reqs 4.640050888061523
Thanks, but no, that didn't change anything for me. Maybe it's because I'm using a conda provided python? I used a different package anyway so I'm not really invested in this issue anymore.
With python 3.6 grequests by itself doesn't seem to query https requests asynchronously. If I comment out the monkey patch I get the following timings:
With
patch_select
I get these timings:This was the minimum change I could find that made py3.6 work, with
aggressive=False
grequests is still synchronous.