Commit 43d48a84 authored by Jason Madden's avatar Jason Madden Committed by GitHub

Merge pull request #1676 from gevent/greenlet0417

Support and require greenlet 0.4.17
parents ca216c77 b6a596cd
...@@ -52,6 +52,7 @@ limit-inference-results=1 ...@@ -52,6 +52,7 @@ limit-inference-results=1
# Pylint 2.4 adds import-outside-toplevel. But we do that a lot to defer imports because of patching. # Pylint 2.4 adds import-outside-toplevel. But we do that a lot to defer imports because of patching.
# Pylint 2.4 adds self-assigning-variable. But we do *that* to avoid unused-import when we # Pylint 2.4 adds self-assigning-variable. But we do *that* to avoid unused-import when we
# "export" the variable and don't have a __all__. # "export" the variable and don't have a __all__.
# Pylint 2.6 adds some python-3-only things that don't apply
disable=wrong-import-position, disable=wrong-import-position,
wrong-import-order, wrong-import-order,
missing-docstring, missing-docstring,
...@@ -74,8 +75,9 @@ disable=wrong-import-position, ...@@ -74,8 +75,9 @@ disable=wrong-import-position,
useless-return, useless-return,
useless-object-inheritance, useless-object-inheritance,
import-outside-toplevel, import-outside-toplevel,
self-assigning-variable self-assigning-variable,
raise-missing-from,
super-with-arguments
[FORMAT] [FORMAT]
# duplicated from setup.cfg # duplicated from setup.cfg
......
...@@ -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.
......
...@@ -6,6 +6,42 @@ ...@@ -6,6 +6,42 @@
.. towncrier release notes start .. towncrier release notes start
20.6.3.dev0 (2020-09-22)
========================
Features
--------
- The embedded libev is now asked to detect the availability of
``clock_gettime`` and use the realtime and/or monotonic clocks, if
they are available.
On Linux, this can reduce the number of system calls libev makes.
Originally provided by Josh Snyder.
See :issue:`issue1648`.
Bugfixes
--------
- The ``DummyThread`` objects created automatically by certain
operations when the standard library threading module is
monkey-patched now match the naming convention the standard library
uses ("Dummy-12345"). Previously (since gevent 1.2a2) they used
"DummyThread-12345".
See :issue:`1659`.
- Fix compatibility with dnspython 2.
.. caution:: This currently means that it can be imported. But it
cannot yet be used. gevent has a pinned dependency on
dnspython < 2 for now.
See :issue:`1661`.
----
20.6.2 (2020-06-16) 20.6.2 (2020-06-16)
=================== ===================
......
...@@ -11,12 +11,20 @@ ...@@ -11,12 +11,20 @@
extern "C" { extern "C" {
#endif #endif
#define GREENLET_VERSION "0.4.16" #define GREENLET_VERSION "0.4.17"
#if PY_VERSION_HEX >= 0x030700A3 #if PY_VERSION_HEX >= 0x030700A3
# define GREENLET_USE_EXC_INFO # define GREENLET_USE_EXC_INFO
#endif #endif
#ifndef GREENLET_USE_CONTEXT_VARS
#ifdef Py_CONTEXT_H
#define GREENLET_USE_CONTEXT_VARS 1
#else
#define GREENLET_USE_CONTEXT_VARS 0
#endif
#endif
typedef struct _greenlet { typedef struct _greenlet {
PyObject_HEAD PyObject_HEAD
char* stack_start; char* stack_start;
...@@ -38,6 +46,9 @@ typedef struct _greenlet { ...@@ -38,6 +46,9 @@ typedef struct _greenlet {
PyObject* exc_traceback; PyObject* exc_traceback;
#endif #endif
PyObject* dict; PyObject* dict;
#if GREENLET_USE_CONTEXT_VARS
PyObject* context;
#endif
} PyGreenlet; } PyGreenlet;
#define PyGreenlet_Check(op) PyObject_TypeCheck(op, &PyGreenlet_Type) #define PyGreenlet_Check(op) PyObject_TypeCheck(op, &PyGreenlet_Type)
......
On CPython, depend on greenlet >= 0.4.17. This version is binary
incompatible with earlier releases on CPython 3.7 and later.
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`.
...@@ -24,8 +24,9 @@ requires = [ ...@@ -24,8 +24,9 @@ requires = [
# See version requirements in setup.py # See version requirements in setup.py
"cffi >= 1.12.3 ; platform_python_implementation == 'CPython'", "cffi >= 1.12.3 ; platform_python_implementation == 'CPython'",
# Python 3.7 requires at least 0.4.14, which is ABI incompatible with earlier # Python 3.7 requires at least 0.4.14, which is ABI incompatible with earlier
# releases. Python 3.9 and 3.10 require 0.4.16 # releases. Python 3.9 and 3.10 require 0.4.16;
"greenlet >= 0.4.16 ; platform_python_implementation == 'CPython'", # 0.4.17 is ABI incompatible with earlier releases.
"greenlet >= 0.4.17 ; platform_python_implementation == 'CPython'",
] ]
[tool.towncrier] [tool.towncrier]
......
...@@ -72,9 +72,9 @@ if [ -d /gevent -a -d /opt/python ]; then ...@@ -72,9 +72,9 @@ if [ -d /gevent -a -d /opt/python ]; then
# The downside is that we must install dependencies manually. # The downside is that we must install dependencies manually.
# NOTE: We can't upgrade ``wheel`` because ``auditwheel`` depends on # NOTE: We can't upgrade ``wheel`` because ``auditwheel`` depends on
# it, and auditwheel is installed in one of these environments. # it, and auditwheel is installed in one of these environments.
python -mpip install -U "cython >= 3.0a5" cffi greenlet setuptools python -mpip install -U "cython >= 3.0a5" cffi 'greenlet >= 0.4.17' setuptools
time (python setup.py bdist_wheel -q > /dev/null) time (python setup.py bdist_wheel -q > /dev/null)
PATH="$OPATH" auditwheel repair --plat manylinux2010_x86_64 dist/gevent*.whl PATH="$OPATH" auditwheel repair dist/gevent*.whl
cp wheelhouse/gevent*.whl /gevent/wheelhouse cp wheelhouse/gevent*.whl /gevent/wheelhouse
python -mpip install -U --no-compile `ls dist/gevent*whl`[test] python -mpip install -U --no-compile `ls dist/gevent*whl`[test]
...@@ -106,5 +106,5 @@ echo Sharing ccache dir at $HOME/.ccache ...@@ -106,5 +106,5 @@ echo Sharing ccache dir at $HOME/.ccache
if [ ! -d $HOME/.ccache ]; then if [ ! -d $HOME/.ccache ]; then
mkdir $HOME/.ccache mkdir $HOME/.ccache
fi fi
docker run --rm -ti -v "$(pwd):/gevent" -v "$LCACHE:/cache" -v "$HOME/.ccache:/ccache" quay.io/pypa/manylinux2010_x86_64 /gevent/scripts/releases/$(basename $0) docker run --rm -ti -v "$(pwd):/gevent" -v "$LCACHE:/cache" -v "$HOME/.ccache:/ccache" ${DOCKER_IMAGE:-quay.io/pypa/manylinux2010_x86_64} /gevent/scripts/releases/$(basename $0)
ls -l wheelhouse ls -l wheelhouse
...@@ -193,7 +193,7 @@ greenlet_requires = [ ...@@ -193,7 +193,7 @@ greenlet_requires = [
# since we compile cython code that extends the greenlet object. # since we compile cython code that extends the greenlet object.
# Binary compatibility would break if the greenlet struct changes. # Binary compatibility would break if the greenlet struct changes.
# (Which it did in 0.4.14 for Python 3.7) # (Which it did in 0.4.14 for Python 3.7)
'greenlet >= 0.4.16; platform_python_implementation=="CPython"', 'greenlet >= 0.4.17; platform_python_implementation=="CPython"',
] ]
# Note that we don't add cffi to install_requires, it's # Note that we don't add cffi to install_requires, it's
......
...@@ -42,6 +42,7 @@ from socket import SOL_SOCKET ...@@ -42,6 +42,7 @@ from socket import SOL_SOCKET
from ssl import SSLWantReadError from ssl import SSLWantReadError
from ssl import SSLWantWriteError from ssl import SSLWantWriteError
from ssl import SSLEOFError
from ssl import CERT_NONE from ssl import CERT_NONE
from ssl import SSLError from ssl import SSLError
from ssl import SSL_ERROR_EOF from ssl import SSL_ERROR_EOF
...@@ -628,9 +629,12 @@ class SSLSocket(socket): ...@@ -628,9 +629,12 @@ class SSLSocket(socket):
if self.timeout == 0.0: if self.timeout == 0.0:
raise raise
self._wait(self._write_event) self._wait(self._write_event)
except SSLEOFError:
break
except OSError as e: except OSError as e:
if e.errno == 0: if e.errno == 0:
# What does this even mean? Seen on 3.7+. # The equivalent of SSLEOFError on unpatched versions of Python.
# https://bugs.python.org/issue31122
break break
raise raise
......
...@@ -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:
......
...@@ -235,11 +235,14 @@ disabled_tests = [ ...@@ -235,11 +235,14 @@ disabled_tests = [
# and this doesn't work reliably on all versions. # and this doesn't work reliably on all versions.
'test_httplib.HeaderTests.test_headers_debuglevel', 'test_httplib.HeaderTests.test_headers_debuglevel',
# These depend on the exact error message produced by the interpreter # On Appveyor with Python 3.8.0 and 3.7.5, this test
# when too many arguments are passed to functions. We can't match # for __class_getitem__ fails. Presumably this was added
# the exact signatures (because Python 2 doesn't support the syntax) # in a patch release (it's not in the PEP.) Sigh.
'test_context.ContextTest.test_context_new_1', # https://bugs.python.org/issue38979
'test_context.ContextTest.test_context_var_new_1', 'test_context.ContextTest.test_contextvar_getitem',
# The same patch that fixed that removed this test,
# because it would now fail.
'test_context.ContextTest.test_context_var_new_2',
] ]
if OSX: if OSX:
......
This diff is collapsed.
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