Coder Social home page Coder Social logo

Comments (4)

spyoungtech avatar spyoungtech commented on July 17, 2024 3

This warning comes from gevent -- This happens if you import the ssl module (or import any other library that, at some point, imports ssl) before importing grequests. The warning was introduced in a recent version of gevent

For example:

# bad
import requests
import grequests

This raises the warning you see. It's a good warning, as this scenario will also lead to misbehavior in using grequests.

Instead, you want to try to make sure you import grequests first before other modules that use patched libraries.

#  OK
import grequests
import requests

Key takeaway: make sure that grequests is imported first.

It's also worth mentioning that grequests can have conflicts with other packages that use gevent (or even modules that gevent patches, in some cases). uWSGI could fall into this category, particularly if configured to use gevent. Though, it's not clear that's the case here.

See also: gevent/gevent#1235

from grequests.

sonion028 avatar sonion028 commented on July 17, 2024

Does this warning need to be dealt with?
Other modules are also using gevent, there is always one to import first, right?

from grequests.

spyoungtech avatar spyoungtech commented on July 17, 2024

Unfortunately, I'm not sure it's possible to say. Really, it depends...

It's hard to predict whether or not the monkey patching between libraries will be compatible... For better or worse, grequests uses gevent.monkey.patch_all(thread=False, select=False)

This may or may not be compatible with how other libraries expect things to be patched.

That said, grequests is generally intended to be used in a standalone fashion. It's best to not use it with other packages that also use gevent or rely on libraries that are patched by gevent.monkey.patch_all(thread=False, select=False) as they may not behave as expected.

from grequests.

Sdamuu avatar Sdamuu commented on July 17, 2024

This warning comes from gevent -- This happens if you import the ssl module (or import any other library that, at some point, imports ssl) before importing grequests. The warning was introduced in a recent version of gevent

For example:

# bad
import requests
import grequests

This raises the warning you see. It's a good warning, as this scenario will also lead to misbehavior in using grequests.

Instead, you want to try to make sure you import grequests first before other modules that use patched libraries.

#  OK
import grequests
import requests

Key takeaway: make sure that grequests is imported first.

It's also worth mentioning that grequests can have conflicts with other packages that use gevent (or even modules that gevent patches, in some cases). uWSGI could fall into this category, particularly if configured to use gevent. Though, it's not clear that's the case here.

See also: gevent/gevent#1235

Thanks!!! It works 😁😁😁

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.