Coder Social home page Coder Social logo

Comments (3)

spyoungtech avatar spyoungtech commented on August 16, 2024 1

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.

from grequests.

ariisan123 avatar ariisan123 commented on August 16, 2024 1

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.

Sos crack man, gracias

from grequests.

spyoungtech avatar spyoungtech commented on August 16, 2024

Glad I could help

from grequests.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.