Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSL infinity recursion error when using this with gevent. #1176

Closed
luxrck opened this issue May 15, 2017 · 4 comments
Closed

SSL infinity recursion error when using this with gevent. #1176

luxrck opened this issue May 15, 2017 · 4 comments

Comments

@luxrck
Copy link

luxrck commented May 15, 2017

reproduce

import gevent.monkey
from requests.packages.urllib3.util.ssl_ import create_urllib3_context

gevent.monkey.patch_all()
create_urllib3_context()
@Lukasa
Copy link
Sponsor Contributor

Lukasa commented May 15, 2017

Sorry, but I can't reproduce: running your code on my machine produces no problem whatsoever. Can you provide the output of pip freeze and python --version?

@luxrck
Copy link
Author

luxrck commented May 15, 2017

os: archlinux
python: 3.6.1
gevent: 1.2.1
requests: 2.14.2

@Lukasa
Copy link
Sponsor Contributor

Lukasa commented May 15, 2017

Based on the fix you provided in #1177, it seems that gevent is monkeypatching the SSLContext object. It is vitally important when you use gevent that you apply the monkeypatch before you import any other code. Code frequently will use from imports to bring objects into their own namespaces, and monkeypatching after doing that will cause code to break.

Rather than force every library in the world to bend to gevent's will, just re-order your code:

import gevent.monkey
gevent.monkey.patch_all()

from requests.packages.urllib3.util.ssl_ import create_urllib3_context
create_urllib3_context()

This will resolve your issues nicely.

@Lukasa Lukasa closed this as completed May 15, 2017
@luxrck
Copy link
Author

luxrck commented May 15, 2017

sure it is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants