Closed mwitteveen closed 3 years ago
Sometimes this can be fixed by making sure grequests
is the first imported module, ensuring that no other modules import modules that need to be patched by gevent.
grequests
relies on gevent's monkeypatching to work. If you import a module that gevent patches before it is patched, it will result in the module being unpatched and thus incompatible.
# bad
import requests
import grequests
# good
import grequests
import requests
In other cases, there are sometimes conflicts between what grequests
patches and what other libraries patch (or dont patch). This seems particularly true of other libraries that either (1) use modules patched by gevent
(like ssl
) or (2) also use gevent
.
Arguably, grequests
does a less-than-ideal (incorrect) thing by performing the monkey patch on import, whereas it may be ideal if grequests left it in the user's control when monkeypatch occurs. Unfortunately, it's probably not something that can be changed as a default this far down the road without breaking everybody using this package.
You can search for other issues in this repo with the gevent
label to find previous discussion and other explanations/workarounds for this and similar issues.
Sometimes this can be fixed by making sure
grequests
is the first imported module, ensuring that no other modules import modules that need to be patched by gevent.
grequests
relies on gevent's monkeypatching to work. If you import a module that gevent patches before it is patched, it will result in the module being unpatched and thus incompatible.# bad import requests import grequests
# good import grequests import requests
In other cases, there are sometimes conflicts between what
grequests
patches and what other libraries patch (or dont patch). This seems particularly true of other libraries that either (1) use modules patched bygevent
(likessl
) or (2) also usegevent
.Arguably,
grequests
does a less-than-ideal (incorrect) thing by performing the monkey patch on import, whereas it may be ideal if grequests left it in the user's control when monkeypatch occurs. Unfortunately, it's probably not something that can be changed as a default this far down the road without breaking everybody using this package.You can search for other issues in this repo with the
gevent
label to find previous discussion and other explanations/workarounds for this and similar issues.
Sos crack man, gracias
Glad I could help
I am having issues using the grequests package in my project.
The issue takes place when i am running pytest on my whole project. Separately all my tests will pass but combining all the tests makes about half of them crash. And this forms an issues when using pytest-cov and pytest-xdist.
After a couple of hours searching what could be wrong i ended up blaming you guys xD.
So the related issue is: https://github.com/gevent/gevent/issues/1016
A warning is given while i run my tests:
=============================== warnings summary =============================== .venv/lib/python3.8/site-packages/grequests.py:22