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

Unable to use python AIOHTTP integration with gunicorn + eventlet, claims aiocontextvars is not installed #630

Closed
TheSHEEEP opened this issue Feb 19, 2020 · 4 comments · Fixed by #701

Comments

@TheSHEEEP
Copy link

Here is the output trying to run the gunicorn service:

[2020-02-19 07:40:53 +0000] [28258] [INFO] Starting gunicorn 20.0.4
[2020-02-19 07:40:53 +0000] [28258] [INFO] Listening at: unix:/var/www/service.sock (28258)
[2020-02-19 07:40:53 +0000] [28258] [INFO] Using worker: eventlet
[2020-02-19 07:40:53 +0000] [28261] [INFO] Booting worker with pid: 28261
[sentry] DEBUG: Setting up integrations (with default = True)
[sentry] DEBUG: Setting up previously not enabled integration flask
[sentry] DEBUG: Setting up previously not enabled integration aiohttp
[2020-02-19 07:40:53 +0000] [28261] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/gunicorn/arbiter.py", line 583, in spawn_worker
worker.init_process()
File "/usr/local/lib/python3.6/dist-packages/gunicorn/workers/geventlet.py", line 99, in init_process
super().init_process()
File "/usr/local/lib/python3.6/dist-packages/gunicorn/workers/base.py", line 119, in init_process
self.load_wsgi()
File "/usr/local/lib/python3.6/dist-packages/gunicorn/workers/base.py", line 144, in load_wsgi
self.wsgi = self.app.wsgi()
File "/usr/local/lib/python3.6/dist-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/usr/local/lib/python3.6/dist-packages/gunicorn/app/wsgiapp.py", line 49, in load
return self.load_wsgiapp()
File "/usr/local/lib/python3.6/dist-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
return util.import_app(self.app_uri)
File "/usr/local/lib/python3.6/dist-packages/gunicorn/util.py", line 358, in import_app
mod = importlib.import_module(module)
File "/usr/lib/python3.6/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 955, in _find_and_load_unlocked
File "", line 665, in _load_unlocked
File "", line 678, in exec_module
File "", line 219, in _call_with_frames_removed
File "/home/titan/Titan/webapp/titanembeds/app.py", line 43, in
debug = True
File "/usr/local/lib/python3.6/dist-packages/sentry_sdk/hub.py", line 80, in _init
client = Client(*args, **kwargs) # type: ignore
File "/usr/local/lib/python3.6/dist-packages/sentry_sdk/client.py", line 80, in init
self._init_impl()
File "/usr/local/lib/python3.6/dist-packages/sentry_sdk/client.py", line 108, in _init_impl
with_defaults=self.options["default_integrations"],
File "/usr/local/lib/python3.6/dist-packages/sentry_sdk/integrations/init.py", line 82, in setup_integrations
type(integration).setup_once()
File "/usr/local/lib/python3.6/dist-packages/sentry_sdk/integrations/aiohttp.py", line 50, in setup_once
"The aiohttp integration for Sentry requires Python 3.7+ "
RuntimeError: The aiohttp integration for Sentry requires Python 3.7+ or aiocontextvars package

I have read in other issues that gevent (and therefore I guess eventlet, too?) interferes with the aiocontextvars package somehow.
Am I simply out of luck in this case if I cannot switch to Python 3.7?

@untitaker
Copy link
Member

Even on Python 3.7 you will have problems getting gevent to harmonize with contextvars/aiocontextvars. The blocker here is gevent itself: gevent/gevent#1407 this still needs to be released, and then we'd have to update the sanity checks in the SDK to allow those gevent versions.

We don't support aiohttp in your scenario because without working contextvars we are unable to prevent contextual data (breadcrumbs, contexts, http request data) from leaking into unrelated errors.

@TheSHEEEP
Copy link
Author

I see. Thanks for the explanation.

It would be nice if this information could be added to the documentation, though:
https://docs.sentry.io/platforms/python/aiohttp

@untitaker
Copy link
Member

Yes we also need to make the error message more informative here.

@untitaker
Copy link
Member

gevent 20.5 is out which fixes this problem

untitaker added a commit that referenced this issue Jun 3, 2020
…701)

Found multiple issues with the asgi middleware:

    lack of warning if contextvars are broken -- as part of that I refactored/unified the error message we give in such situations, also added more information as gevent just recently released a version that deals with contextvars better
    exposed methods that were meant for overriding.. but all that is done in there can be done in event processors, so we make them private

Fix #630
Fix #700
Fix #694
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

Successfully merging a pull request may close this issue.

2 participants