Commit eb2e3f11 authored by Jason Madden's avatar Jason Madden

We no longer need to monkey-patch contextvars on 3.7+.

Fixes #1656

Also disable 32-bit manylinux builds because of https://github.com/cython/cython/issues/3840
parent a1b6c3b9
...@@ -279,18 +279,20 @@ jobs: ...@@ -279,18 +279,20 @@ jobs:
- mkdir -p $HOME/.cache/pip - mkdir -p $HOME/.cache/pip
- chmod a+w $HOME/.cache/pip - chmod a+w $HOME/.cache/pip
- stage: test # 32-bit manylinux temporarily commentted out.
name: 32-bit manylinux wheels (all Pythons) # https://github.com/cython/cython/issues/3840 has surfaced again.
language: python # - stage: test
services: docker # name: 32-bit manylinux wheels (all Pythons)
env: DOCKER_IMAGE=quay.io/pypa/manylinux2010_i686 PRE_CMD=linux32 # language: python
install: docker pull $DOCKER_IMAGE # services: docker
script: bash scripts/releases/make-manylinux # env: DOCKER_IMAGE=quay.io/pypa/manylinux2010_i686 PRE_CMD=linux32
before_script: # install: docker pull $DOCKER_IMAGE
- python -mpip install -U pip twine # script: bash scripts/releases/make-manylinux
- chmod a+rwx $HOME/.cache # before_script:
- mkdir -p $HOME/.cache/pip # - python -mpip install -U pip twine
- chmod a+rwx $HOME/.cache/pip # - chmod a+rwx $HOME/.cache
# - mkdir -p $HOME/.cache/pip
# - chmod a+rwx $HOME/.cache/pip
# Lint the code. Because this is a separate job, even if it fails fast # Lint the code. Because this is a separate job, even if it fails fast
# the tests will still run. Put it at the top for fast feedback. # the tests will still run. Put it at the top for fast feedback.
......
On CPython, depend on greenlet >= 0.4.17. This version is binary On CPython, depend on greenlet >= 0.4.17. This version is binary
incompatible with earlier releases on CPython 3.7 and later. Note that incompatible with earlier releases on CPython 3.7 and later.
gevent does not rely on its new support for context variables since
gevent provides the same API to older versions of Python. On Python 3.7 and above, the module ``gevent.contextvars`` is no
longer monkey-patched into the standard library. contextvars are now
both greenlet and asyncio task local. See :issue:`1656`.
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
Cooperative ``contextvars`` module. Cooperative ``contextvars`` module.
This module was added to Python 3.7. The gevent version is available This module was added to Python 3.7. The gevent version is available
on all supported versions of Python. on all supported versions of Python. However, see an important note
about gevent 20.9.
Context variables are like greenlet-local variables, just more Context variables are like greenlet-local variables, just more
inconvenient to use. They were designed to work around limitations in inconvenient to use. They were designed to work around limitations in
...@@ -23,6 +24,17 @@ from :pep:`567` and doesn't have much optimization. In particular, setting ...@@ -23,6 +24,17 @@ from :pep:`567` and doesn't have much optimization. In particular, setting
context values isn't constant time. context values isn't constant time.
.. versionadded:: 1.5a3 .. versionadded:: 1.5a3
.. versionchanged:: NEXT
On Python 3.7 and above, this module is no longer monkey-patched
in place of the standard library version.
gevent depends on greenlet 0.4.17 which includes support for context variables.
This means that any number of greenlets can be running any number of asyncio tasks
each with their own context variables. This module is only greenlet aware, not
asyncio task aware, so its use is not recommended on Python 3.7 and above.
On previous versions of Python, this module continues to be a solution for
backporting code. It is also available if you wish to use the contextvar API
in a strictly greenlet-local manner.
""" """
from __future__ import absolute_import from __future__ import absolute_import
from __future__ import division from __future__ import division
......
...@@ -157,6 +157,7 @@ else: ...@@ -157,6 +157,7 @@ else:
WIN = sys.platform.startswith("win") WIN = sys.platform.startswith("win")
PY36 = sys.version_info[:2] >= (3, 6) PY36 = sys.version_info[:2] >= (3, 6)
PY37 = sys.version_info[:2] >= (3, 7)
class _BadImplements(AttributeError): class _BadImplements(AttributeError):
""" """
...@@ -583,7 +584,16 @@ def patch_contextvars(): ...@@ -583,7 +584,16 @@ def patch_contextvars():
.. versionchanged:: 20.04.0 .. versionchanged:: 20.04.0
Clarify that the backport is also patched. Clarify that the backport is also patched.
.. versionchanged:: NEXT
This now does nothing on Python 3.7 and above.
gevent now depends on greenlet 0.4.17, which
natively handles switching context vars when greenlets are switched.
Older versions of Python that have the backport installed will
still be patched.
""" """
if PY37:
return
try: try:
__import__('contextvars') __import__('contextvars')
except ImportError: except ImportError:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment