Changes for 1.2#
Testing on Python 3.5 now uses Python 3.5.3 due to SSL changes. See issue #943.
Linux CI has been updated from Ubuntu 12.04 to Ubuntu 14.04 since the former has reached EOL.
Linux CI now tests on PyPy2 5.7.1, updated from PyPy2 5.6.0.
Linux CI now tests on PyPy3 3.5-5.7.1-beta, updated from PyPy3 3.3-5.5-alpha.
Python 2 sockets are compatible with the
SOCK_CLOEXECflag found on Linux. They no longer pass the socket type or protocol to
connectis called. Reported in issue #944 by Bernie Hackett.
argparse. See issue #947.
Update to version 1.3.1 of
tblibto fix issue #954, reported by ml31415.
Fix the name of the
gevent.socket.getaddrinfo()to be correct on Python 3. This would cause callers using keyword arguments to raise a
TypeError. Reported in issue #960 by js6626069. Likewise, correct the argument names for
socketpairon Python 2, although they cannot be called with keyword arguments under CPython.
gethost*functions take different argument names under CPython and PyPy. gevent follows the CPython convention, although these functions cannot be called with keyword arguments on CPython.
The previously-singleton exception objects
cancel_wait_exwere converted to classes. On Python 3, an exception object is stateful, including references to its context and possibly traceback, which could lead to objects remaining alive longer than intended.
Make sure that
python -m gevent.monkey <script>runs code in the global scope, not the scope of the
mainfunction. Fixed in pull request #975 by Shawn Bohrer.
CI services now test on 3.6.0.
socket.socketpairfor all Python 3 versions. This was added to Python 3.5, but tests were only added in 3.6. (For versions older than 3.4 this is a gevent extension.) Previously this was not supported on any Python 3 version.
subprocess.__all__for 3.6 compatibility.
_DummyThreadobjects created by calling
threading.current_thread()from inside a raw
greenlet.greenletin a system with monkey-patched
threadingnow clean up after themselves when the greenlet dies (
_DummyThreadshave always cleaned up). This requires the use of a
weakref.ref(and may not be timely on PyPy). Reported in issue #918 by frozenoctobeer.
Build OS X wheels with
-D_DARWIN_FEATURE_CLOCK_GETTIME=0for compatibility with OS X releases before 10.12 Sierra. Reported by Ned Batchelder in issue #916.
The c-ares DNS resolver ignores bad flags to getnameinfo, like the system resolver does. Discovered when cleaning up the DNS resolver tests to produce more reliable results. See issue #774.
1.2a2 (Dec 9, 2016)#
Update libev to version 4.23.
MAKEenvironment variable to specify the make command on non-Windows systems for ease of development on BSD systems where
makeis BSD make and
gmakeis GNU make (gevent requires GNU make). See issue #888.
1.2a1 (Oct 27, 2016)#
Support for Python 2.6 has been removed. See pull request #766.
gevent.coroswhich was replaced by
gevent.lockand has been deprecated since 1.0b2.
The internal implementation modules
gevent.corecffihave been moved. Please import from
gevent.coreinstead; this has always been the only documented place to import from.
Libraries and Installation#
Update libev to version 4.22 (was 4.20).
Update tblib to 1.3.0.
Update Cython to 0.25 (was 0.23.5).
Update c-ares to version 1.12.0 (was 1.10.0) (release notes).
For the benefit of downstream package maintainers, gevent is now tested with c-ares and libev linked dynamically and not embedded (i.e., using the system libraries). However, only the versions shipped with gevent are tested and known to work.
The repository directory layout has been changed to make it easier to include third-party dependencies. Likewise, the setup.py script has been split to make it easier to build third-party dependencies.
PyPy/CFFI: The corecffi native extension is now only built at installation time. Previously, if it wasn’t available, a build was attempted at every import. This could lead to scattered “gevent” directories and undependable results.
setuptools is now required at build time on all platforms. Previously it was only required for Windows and PyPy.
gevent.pywsginow checks that the values passed to
start_responsedo not contain a carriage return or newline in order to prevent HTTP response splitting (header injection), raising a
ValueErrorif they do. See issue #775.
Incoming headers containing an underscore are no longer placed in the WSGI environ. See issue #819.
Errors logged by
WSGIHandlerno longer print the entire WSGI environment by default. This avoids possible information disclosure vulnerabilities. Applications can also opt-in to a higher security level for the WSGI environment if they choose and their frameworks support it. Originally reported in pull request #779 by sean-peters-au and changed in pull request #781.
As mentioned above, Python 2.6 is no longer supported.
Python 3.6 is now tested on POSIX platforms. This includes a few notable changes:
SSLContext.wrap_socket accepts the
sessionparameter, though this parameter isn’t useful prior to 3.6.
SSLSocket.recv(0) or read(0) returns an empty byte string. This is a fix for Python bug #23804 which has also been merged into Python 2.7 and Python 3.5.
PyPy3 5.5.0 alpha (supporting Python 3.3.5) is now tested and passes the test suite. Thanks to btegs for issue #866, and Fabio Utzig for pull request #826. Note that PyPy3 is not optimized for performance either by the PyPy developers or under gevent, so it may be significantly slower than PyPy2.
reload(site)no longer fails with a
TypeErrorif gevent has been imported. Reported in issue #805 by Jake Hilton.
sendallon a non-blocking socket could spuriously fail with a timeout.
gevent.select.select()is given a negative timeout argument, raise an exception like the standard library does.
gevent.select.select()is given closed or invalid file descriptors in any of its lists, raise the appropriate
EBADFexception like the standard library does. Previously, libev would tend to return the descriptor as ready. In the worst case, this adds an extra system call, but may also reduce latency if descriptors are ready at the time of entry.
gevent.select.poll.unregister()raises an exception if fd is not registered, like the standard library.
gevent.select.poll.poll()returns an event with
POLLNVALfor registered fds that are invalid. Previously it would tend to report both read and write events.
read1method when in read mode, and generally only exposes methods appropriate to the mode it is in.
FileObjectPosixsupports a bufsize of 0 in binary write modes. Reported in issue #840 by Mike Lang.
BlockingIOError(and possibly others) get raised instead of returning the errno due to the refactoring of the exception hierarchy in Python 3.3. Now the errno is returned. Reported in issue #841 by Dana Powers.
Unhandled exception reports that kill a greenlet now include a timestamp. See issue #137.
sys.stderrhas been monkey-patched (not recommended), exceptions that the hub reports aren’t lost and can still be caught. Reported in issue #825 by Jelle Smet.
FileObjectimplementations are more consistent with each other. Note: Writing to the io property of a FileObject should be considered deprecated.
Timeout exceptions (and other asynchronous exceptions) could cause the BackdoorServer to fail to properly manage the stdout/stderr/stdin values. Reported with a patch in pull request #874 by stefanmh.
The BackDoorServer now tracks spawned greenlets (connections) and kills them in its
Default to AF_INET6 when binding to all addresses (e.g., “”). This supports both IPv4 and IPv6 connections (except on Windows). Original change in pull request #495 by Felix Kaiser.
pywsgi/performance: Chunks of data the application returns are no longer copied before being sent to the socket when the transfer-encoding is chunked, potentially reducing overhead for large responses.
concurrent.futures.ThreadPoolExecutorvariant that always uses native threads even when the system has been monkey-patched) on platforms that have
concurrent.futuresavailable (Python 3 and Python 2 with the
futuresbackport installed). This is helpful for, e.g., grpc. Reported in issue #786 by Markus Padourek.
Native threads created before monkey-patching threading can now be joined. Previously on Python < 3.4, doing so would raise a
LoopExiterror. Reported in issue #747 by Sergey Vasilyev.
On Python 2.7.9 and above (more generally, when the SSL backport is present in Python 2),
gevent.ssl.get_server_certificate()would raise a
ValueErrorif the system wasn’t monkey-patched. Reported in issue #801 by Gleb Dubovik.
On Python 2.7.9 and Python 3, closing an SSL socket in one greenlet while it’s being read from or written to in a different greenlet is less likely to raise a
TypeErrorinstead of a
ValueError. Reported in issue #800 by Kevin Chen.
Setting SIGCHLD to SIG_IGN or SIG_DFL after
gevent.subprocesshad been used previously could not be reversed, causing
Popen.waitand other calls to hang. Now, if SIGCHLD has been ignored, the next time
gevent.subprocessis used this will be detected and corrected automatically. (This potentially leads to issues with
os.popen()on Python 2, but the signal can always be reset again. Mixing the low-level process handling calls, low-level signal management and high-level use of
gevent.subprocessis tricky.) Reported in issue #857 by Chris Utz.
send_signalno longer attempt to send signals to processes that are known to be exited.
Several backwards compatible updates to the subprocess module have
been backported from Python 3 to Python 2, making
gevent.subprocess smaller, easier to maintain and in some cases
Popen objects can be used as context managers even on Python 2. The high-level API functions (
call, etc) use this for added safety.
gevent.subprocessmodule now provides the
gevent.subprocess.run()function in a cooperative way even when the system is not monkey patched, on all supported versions of Python. (It was added officially in Python 3.5.)
Popen objects save their args attribute even on Python 2.
gevent.subprocess.TimeoutExpiredis defined even on Python 2, where it is a subclass of the
gevent.timeout.Timeoutexception; all instances where a
Timeoutexception would previously be thrown under Python 2 will now throw a
check_call) accepts the timeout keyword argument on Python 2. This is standard on Python 3, but a gevent extension on Python 2.
gevent.subprocess.check_output()accepts the timeout and input arguments on Python 2. This is standard on Python 3, but a gevent extension on Python 2.