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

Infinite Recursion when making request #236

Closed
bman7777 opened this issue Jun 2, 2020 · 3 comments
Closed

Infinite Recursion when making request #236

bman7777 opened this issue Jun 2, 2020 · 3 comments

Comments

@bman7777
Copy link

bman7777 commented Jun 2, 2020

I am seeing an issue on 1.22.1. When making a request via a celery worker (which uses gevent) I get an infinite recursion, here is the callstack:

RecursionError: maximum recursion depth exceeded while calling a Python object
[Previous line repeated 457 more times]
super(SSLContext, SSLContext).options.__set__(self, value)
File "/usr/local/lib/python3.7/ssl.py", line 518, in options
super(SSLContext, SSLContext).options.__set__(self, value)
File "/usr/local/lib/python3.7/ssl.py", line 518, in options
super(SSLContext, SSLContext).options.__set__(self, value)
File "/usr/local/lib/python3.7/ssl.py", line 518, in options
context.options |= options
File "/usr/local/lib/python3.7/site-packages/urllib3/util/ssl_.py", line 276, in create_urllib3_context
cert_reqs=resolve_cert_reqs(self.cert_reqs),
File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 344, in connect
conn.connect()
File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 976, in _validate_conn
self._validate_conn(conn)
File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 381, in _make_request
chunked=chunked,
File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 677, in urlopen
return wrapped(*args, **kwargs)
**File "/usr/local/lib/python3.7/site-packages/instana/instrumentation/urllib3.py", line 67, in urlopen_with_instana**
timeout=timeout
File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 449, in send

I'm wondering if this has to do with recent changes to add gevent support, I found a similar issue resolved here:

gevent/gevent#1016

I will try to step back to an older version and see if I can find where it was introduced.

@pglombardo
Copy link
Contributor

Hi @bman7777 - thanks for reporting.

gevent does have some issues filed on this and the general solution seems to be "monkey patch earlier" (re: gevent.monkey.patch_all()):

gevent/gevent#1531
gevent/gevent#1141

But this might also be related to AUTOWRAPT_BOOTSTRAP. If you are using this method to instrument your python applications, there is a known issue where autowrapt doesn't work correctly with gevent. This is because autowrapt loads the instana package before gevent can do its own monkey patching.

I added a note on this here:
https://www.instana.com/docs/ecosystem/python/#activating-without-code-changes

This method of activation will not work with applications based on gevent. This is because gevent must be activated and monkey.patch_all() called first.

If this is the case, then you should either migrate to Python AutoTrace or if you are using any custom calls, the manual installation method (by adding import instana to your code):

https://www.instana.com/docs/ecosystem/python/troubleshooting/#migrating-to-python-autotrace
https://www.instana.com/docs/ecosystem/python/#activating-with-code-changes

Let me know if this is the case for you and if this helps!

@pglombardo
Copy link
Contributor

I'm not completely sure yet if the AUTOWRAPT_BOOTSTRAP issue affects you but I added a new section in our documentation to at least explain the known issue:
https://www.instana.com/docs/ecosystem/python/troubleshooting/#autowrapt_bootstrap-gevent--recursionerror

@bman7777
Copy link
Author

bman7777 commented Jun 9, 2020

This did end up resolving my issue. Thank you!

@bman7777 bman7777 closed this as completed Jun 9, 2020
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