We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 85c15e2 commit 807abc6Copy full SHA for 807abc6
sentry_sdk/utils.py
@@ -748,12 +748,21 @@ def _get_contextvars():
748
https://github.com/gevent/gevent/issues/1407
749
"""
750
if not _is_threading_local_monkey_patched():
751
+ # aiocontextvars is a PyPI package that ensures that the contextvars
752
+ # backport (also a PyPI package) works with asyncio under Python 3.6
753
+ #
754
+ # Import it if available.
755
+ if not PY2 and sys.version_info < (3, 7):
756
+ try:
757
+ from aiocontextvars import ContextVar # noqa
758
+
759
+ return True, ContextVar
760
+ except ImportError:
761
+ pass
762
763
try:
764
from contextvars import ContextVar
765
- if not PY2 and sys.version_info < (3, 7):
- import aiocontextvars # noqa
-
766
return True, ContextVar
767
except ImportError:
768
pass
0 commit comments