File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -748,12 +748,21 @@ def _get_contextvars():
748
748
https://github.com/gevent/gevent/issues/1407
749
749
"""
750
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
+
751
763
try :
752
764
from contextvars import ContextVar
753
765
754
- if not PY2 and sys .version_info < (3 , 7 ):
755
- import aiocontextvars # noqa
756
-
757
766
return True , ContextVar
758
767
except ImportError :
759
768
pass
You can’t perform that action at this time.
0 commit comments