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.
-D_DARWIN_FEATURE_CLOCK_GETTIME=0for compatibility with OS X releases before 10.12 Sierra. Reported by Ned Batchelder in issue #916.
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.
SSLContexton Python versions that support it. Added in pull request #904 by Arcadiy Ivanov.
gevent.coroswhich was replaced by
gevent.lockand has been deprecated since 1.0b2.
gevent.corecffihave been moved. Please import from
gevent.coreinstead; this has always been the only documented place to import from.
/bin/shinto the configuration command line, instead relying on
shbeing on the
PATH, as recommended by the standard. Fixed in pull request #809 by Fredrix Fornwall.
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.
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.
sessionparameter, though this parameter isn’t useful prior to 3.6.
gevent.selectexport all the attributes from their corresponding standard library counterpart.
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.
selectors.SelectSelectoris properly monkey-patched regardless of the order of imports. Reported in issue #835 by Przemysław Węgrzyn.
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.
Poolnow return whether
join()returned with an empty group. Suggested by Filippo Sironi in pull request #503.
PriorityQueuenow ensures that an initial items list is a valid heap. Fixed in pull request #793 by X.C.Dong.
gevent.signal()) now verifies that its handler argument is callable, raising a
TypeErrorif it isn’t. Reported in issue #818 by Peter Renström.
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.
gevent.os.waitpid()function is cooperative in more circumstances. Reported in issue #878 by Heungsub Lee.
FileObjectimplementations are more consistent with each other. Note: Writing to the io property of a FileObject should be considered deprecated.
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.
LoopExiterror. Reported in issue #747 by Sergey Vasilyev.
gevent.ssl.get_server_certificate()would raise a
ValueErrorif the system wasn’t monkey-patched. Reported in issue #801 by Gleb Dubovik.
TypeErrorinstead of a
ValueError. Reported in issue #800 by Kevin Chen.
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
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.)
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.
sendallon a non-blocking socket could spuriously fail with a timeout.
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.
selectors.SelectSelectoris properly monkey-patched regardless of the order of imports. Reported in issue #835 by Przemysław Węgrzyn.
reload(site)no longer fails with a
TypeErrorif gevent has been imported. Reported in issue #805 by Jake Hilton.
waitto return prematurely. Reported in issue #771 by Sergey Vasilyev.
gevent.os.fork_and_watch()was being ignored.
gevent.queue.Channelis now correctly iterable, instead of raising a
socket.socket.recvmsg_into()on platforms where they are defined. Initial pull request #773 by Jakub Klama.
threading.RLocknow properly blocks (or deadlocks) in
acquireif the default value for timeout of -1 is used (which differs from gevent’s default of None). The
acquiremethod also raises the same
ValueErrorexceptions that the standard library does for invalid parameters. Reported in issue #750 by Joy Zheng.
Eventthat made it return
Falsewhen the event was set and cleared by the same greenlet before allowing a switch to already waiting greenlets. (Found by the 3.4 and 3.5 standard library test suites; the same as Python bug 13502. Note that the Python 2 standard library still has this race condition.)
AsyncResultnow wake waiting greenlets in the same (unspecified) order. Previously,
AsyncResulttended to use a FIFO order, but this was never guaranteed. Both classes also use less per-instance memory.
pywsgierror or request log stream no longer produces extra newlines. Reported in issue #756 by ael-code.
patch_all()is called with
osset to False (not the default) but
signalis still True (the default). This combination of parameters will cause signal handlers for
SIGCHLDto not get called. In the future this might raise an error. Reported by Josh Zuech.
patch_all()is called more than once with different arguments. That causes the cumulative set of all True arguments to be patched, which may cause unexpected results.
sendall()method of a gevent SSL socket that has a timeout now returns immediately (like the standard library does), instead of incorrectly raising
ssl.SSLEOFError. (Note that sending empty data with the
send()method does raise
SSLEOFErrorin both gevent and the standard library.) Reported in issue #719 by Mustafa Atik and Tymur Maryokhin, with a reproducible test case provided by Timo Savola.
LoopExit. Reported in issue #728 by Garrett Heel.
OverflowErrorwhen using the
readlinemethod of the WSGI input stream without a size hint or with a large size hint when the client is uploading a large amount of data. (This only impacted CPython 2; PyPy and Python 3 already handled this.) Reported in issue #289 by ggjjlldd, with contributions by Nathan Hoad.
BaseServerand its subclasses like
WSGIServeravoid allocating a new closure for each request, reducing overhead.
SSLSocketnow raises the same
ValueErrorthe standard library does, instead of an
AttributeError. Found by updating gevent’s copy of the standard library test cases. Initially reported in issue #735 by Dmitrij D. Czarkoff.
unwrap()and SNI callbacks. Also raise the correct exceptions for unconnected SSL sockets and properly validate SSL hostnames. Found via updated standard library tests.
socket.socket.sendfile(). Found via updated standard library tests.
set_inheritable(). Found via updated standard library tests.
sslinterfaces on any Python 2 version that supplies them, not just on the versions it officially shipped with. Some Linux distributions, including RedHat/CentOS and Amazon have backported the changes to older versions. Reported in issue #702.
__del__method, something done in the popular libraries
urllib3. Due to this and other Cython related issues, the Semaphore class is no longer compiled by Cython on PyPy. This means that it is now traceable and not exactly as atomic as the Cython version, though the overall semantics should remain the same. Reported in issue #704 by Shaun Crampton.
PATH_INFOentry is decoded from URL escapes using latin-1, not UTF-8. This improves compliance with PEP 3333 and compatibility with some frameworks like Django. Fixed in pull request #712 by Ruben De Visscher.
ssl.SSLError, a change introduced in Python 3.2).
sendallmethod could completely ignore timeouts in some cases. The timeout now refers to the total time taken by
sendallmethod should no longer raise
SSL3_WRITE_PENDINGin rare cases when sending large buffers. Reported in issue #317.
gevent.signal.signal()now allows resetting (SIG_DFL) and ignoring (SIG_IGN) the SIGCHLD signal at the process level (although this may allow race conditions with libev child watchers). Reported in issue #696 by Adam Ning.
gevent.spawn_raw()now accepts keyword arguments, as previously (incorrectly) documented. Reported in issue #680 by Ron Rothman.
cffiis installed before gevent is installed. To use the CFFI backend, set the environment variable
GEVENT_CORE_CFFI_ONLYbefore starting Python. This can aid debugging in some cases and helps ensure parity across all combinations of supported platforms.
argsattribute is set to
None, just like the Cython backend does. It also only allows
argsto be a tuple or
None, again matching the Cython backend.
sys.getfilesystemencoding()like the Cython backend.
gevent._utilwere removed. These haven’t been used or tested since 1.1b1.
Python 3: The SSLSocket class should return an empty
object on an EOF instead of a
str. Fixed in pull request #674 by Dahoon
Python 2: Workaround a buffering bug in the stdlib
FileObjectPosix to be slower than necessary in some
cases. Reported in issue #675 by WGH-.
PyPy: Fix a crash. Reported in issue #676 by Jay Oster.
There are some remaining, relatively rare, PyPy crashes, but their ultimate cause is unknown (gevent, CFFI, greenlet, the PyPy GC?). PyPy users can contribute to issue #677 to help track them down.
PyPy: Exceptions raised while handling an error raised by a loop callback function behave like the CPython implementation: the exception is printed, and the rest of the callbacks continue processing.
If a Hub object with active watchers was destroyed and then another
one created for the same thread, which itself was then destroyed with
destroy_loop=True, the process could crash. Documented in
issue #237 and fix based on pull request #238, both by Jan-Philip Gehrcke.
Python 3: Initializing gevent’s hub for the first time
simultaneously in multiple native background threads could fail with
ImportError. Reported in issue #687 by
gevent.lock.Semaphoresubclasses. If monkey-patched, this could also apply to
threading.Semaphoreobjects. Reported in issue #660 by Jay Oster.
WSGIHandlerto handle invalid HTTP client requests. Reported by not-bob.
WSGIServermore robustly supports
Logger-like parameters for
error_log(as introduced in 1.1b1, this could cause integration issues with gunicorn). Reported in issue #663 by Jay Oster.
_DummyThreadobjects, created in a monkey-patched system when
threading.current_thread()is called in a new greenlet (which often happens implicitly, such as when logging) are much lighter weight. For example, they no longer allocate and then delete a
Semaphore, which is especially important for PyPy.
gevent.pywsgiformats the status code correctly on Python 3. Reported in issue #664 by Kevin Chen.
gevent.lock.Semaphore, which was unintentionally removed as part of making
Semaphoreatomic on PyPy on 1.1b1. Reported in issue #666 by Ivan-Zhu.
gevent.subprocessworks under Python 3.5. In general, Python 3.5 has preliminary support. Reported in issue #653 by Squeaky.
timeoutargument even if there is no way to communicate with the child process (none of stdin, stdout and stderr were set to
PIPE). Noticed as part of the Python 3.5 test suite for the new function
subprocess.runbut impacts all versions (
timeoutis an official argument under Python 3 and a gevent extension with slightly different semantics under Python 2).
Queue.peek. Reported in issue #647 by Kevin Chen.
gevent.signalas a callable, which, depending on the order of imports, could be broken after the addition of the
gevent.signalmodule. Reported in issue #648 by Sylvain Zimmer.
LoopExitinstead of completing the expected blocking operation. Note that performing gevent blocking operations in the top-level of a module is typically not recommended, but this situation can arise when monkey-patching existing scripts. Reported in issue #651 and issue #652 by Mike Kaplinskiy.
waitpidnow work for the pids returned by the (monkey-patched)
pty.forkfunctions in the same way they do for the
os.forkfunction. Reported in issue #650 by Erich Heine.
WSGIHandlerdo a better job detecting and reporting potential encoding errors for headers and the status line during
start_response()as recommended by the WSGI specification. In addition, under Python 2, unnecessary encodings and decodings (often a trip through the ASCII encoding) are avoided for conforming applications. This is an enhancement of an already documented and partially enforced constraint: beginning in 1.1a1, under Python 2,
u'abc'would typically previously have been allowed, but
u'\u1f4a3'would not; now, neither will be allowed, more closely matching the specification, improving debugability and performance and allowing for better error handling both by the application and by gevent (previously, certain encoding errors could result in gevent writing invalid/malformed HTTP responses). Reported by Greg Higgins and Carlos Sanchez.
PYTHONOPTIMIZE. Previously these would go undetected if optimizations were enabled, potentially leading to erratic, difficult to debug behaviour.
peekwas called on an empty
Queue. Reported in issue #643 by michaelvol.
SIGCHLDhandlers specified to
gevent.signal.signal()work with the child watchers that are used by default. Also make
gevent.os.waitpid()work with a first argument of -1. (Also applies to the corresponding monkey-patched stdlib functions.) Noted by users of gunicorn.
socket.makefile. Reported in issue #644 by Karan Lyons.
gevent.monkey.patch_builtinson Python 2 when the future library is also installed. Reported by Carlos Sanchez.
ImportErrorif the CFFI module backing
gevent.coreneeds to be compiled when the hub is initialized (due to a missing or invalid
__pycache__directory). Now, the module will be automtically compiled when gevent is imported (this may produce compiler output on stdout). Reported in issue #619 by Thinh Nguyen and issue #631 by Andy Freeland, with contributions by Jay Oster and Matt Dupre.
gevent.socket.socket:sendallwith large inputs. bench_sendall.py now performs about as well on PyPy as it does on CPython, an improvement of 10x (from ~60MB/s to ~630MB/s). See this pypy bug for details.
gevent.socket.wait. Reported in #635 by lanstin.
gevent.socket.socket:sendtoproperly respects the socket’s blocking status (meaning it can raise EWOULDBLOCK now in cases it wouldn’t have before). Reported in pull request #634 by Mike Kaplinskiy.
threaded resolverare no longer always printed to stderr since they are usually out of the programmer’s control and caught explicitly. (Programming errors like
TypeErrorare still printed.) Reported in issue #617 by Jay Oster and Carlos Sanchez.
gevent.idle(). Reported in issue #639 by chilun2008.
imap_unordered()methods of a pool-like object support a
maxsizeparameter to limit the number of results buffered waiting for the consumer. Reported in issue #638 by Sylvain Zimmer.
gevent.queue.Queuenow consistently orders multiple blocked waiting
getcallers in the order they arrived. Previously, due to an implementation quirk this was often roughly the case under CPython, but not under PyPy. Now they both behave the same.
gevent.queue.Queuenow supports the
c-ares resolverunder PyPy. Note that its performance characteristics are probably sub-optimal.
gevent.monkey.patch_builtinscould cause PyPy to crash. Reported in issue #618 by Jay Oster.
gevent.kill()raises the correct exception in the target greenlet. Reported in issue #623 by Jonathan Kamens.
FileObjectPosix; this fixes e.g., help() on Python 3 when monkey-patched.
setup.pycan be run from a directory containing spaces. Reported in issue #319 by Ivan Smirnov.
setup.pycan build with newer versions of clang on OS X. They enforce the distinction between CFLAGS and CPPFLAGS.
gevent.lock.Semaphoreis atomic on PyPy, just like it is on CPython. This comes at a small performance cost on PyPy.
successfulvalue to False when killing a greenlet before it ran with a non-default exception. Fixed in pull request #608 by Heungsub Lee.
os.waitpid()to become unreliable due to the use of signals on POSIX platforms. This was especially noticeable when using
gevent.subprocessin combination with
multiprocessing. Now, the monkey-patched
osmodule provides a
waitpid()function that seeks to ameliorate this. Reported in issue #600 by champax and issue #452 by Łukasz Kawczyński.
select.poll, provide a gevent-friendly
gevent.select.polland corresponding monkey-patch. Implemented in pull request #604 by Eddi Linder.
gevent.thread.allocate_lock()(and so a monkey-patched standard library
allocate_lock()) more closely matches the behaviour of the builtin: an unlocked lock cannot be released, and attempting to do so throws the correct exception (
thread.erroron Python 2,
RuntimeErroron Python 3). Previously, over-releasing a lock was silently ignored. Reported in issue #308 by Jędrzej Nowak.
gevent.fileobject.FileObjectThreaduses the threadpool to close the underling file-like object. Reported in issue #201 by vitaly-krugl.
pywsgi handleris handled more robustly, resulting in “HTTP 400 bad request” responses instead of a 500 error or, in the worst case, a server-side hang. Reported in issue #229 by Björn Lindqvist.
threadingmodule before using
gevent.monkey.patch_all()no longer causes Python 3.4 to fail to get the
reprof the main thread, and other CPython platforms to return an unjoinable DummyThread. (Note that this is not recommended.) Reported in issue #153.
iopackage to implement
FileObjectPosix. This unifies the code with the Python 3 implementation, and fixes problems with using
seek(). See issue #151.
spawn_later(), as well as the
Greenletconstructor, immediately produce useful
TypeErrorsif asked to run something that cannot be run. Previously, the spawned greenlet would die with an uncaught
TypeErrorthe first time it was switched to. Reported in issue #119 by stephan.
ThreadPool.applyno longer raises a
geton the result still could; you must be careful to use the correct hub). Reported in issue #131 by 8mayday.
monkey-patched, the module-level lock in the
loggingmodule is made greenlet-aware, as are the instance locks of any configured handlers. This makes it safer to import modules that use the standard pattern of creating a module-level
Loggerinstance before monkey-patching. Configuring
loggingwith a basic configuration and then monkey-patching is also safer (but not configurations that involve such things as the
threading.RLockunder Python 3.
importlib. Reported in issue #615 by Daniel Mizyrycki. (The same thing could happen under Python 2 if a
threading.RLockwas held around the monkey-patching call; this is less likely but not impossible with import hooks.)
logging.Loggerinstance for its
error_logparameters. Take care that the system is fully monkey-patched very early in the process’s lifetime if attempting this, and note that non-file handlers have not been tested. Fixes issue #106.
imap_unorderednow accept multiple iterables.
Groupmapping/application functions should now have the original traceback.
gevent.threadpool.ThreadPool.apply()now raises any exception raised by the called function, the same as
Pooland the builtin
apply()function. This obsoletes the undocumented
apply_efunction. Original PR issue #556 by Robert Estelle.
patch_selecton Python 3.4. See issue #591.
gevent.monkeymodule allow knowing what was patched. Discussed in issue #135 and implemented in pull request #325 by Nathan Hoad.
gevent.socket.socket.sendall()supports arbitrary objects that implement the buffer protocol (such as ctypes structures), just like native sockets. Reported in issue #466 by tzickel.
onerrorattribute present in CFFI 1.2.0 for better signal handling under PyPy. Thanks to Armin Rigo and Omer Katz. (See https://bitbucket.org/cffi/cffi/issue/152/handling-errors-from-signal-handlers-in)
gevent.subprocessmodule is closer in behaviour to the standard library under Python 3, at least on POSIX. The
start_new_sessionarguments are now implemented, as are the
timeoutparameters to various functions. Under Python 2, the previously undocumented
Popen.communicateraises an exception like its Python 3 counterpart.
gevent.subprocessmodule no longer leaks file descriptors. Reported in pull request #374 by 陈小玉.
echoserver.pyno longer binds to the standard X11 TCP port. Reported in issue #485 by minusf.
gevent.iwait()no longer throws
LoopExitif the caller switches greenlets between return values. Reported and initial patch in issue #467 by Alexey Borzenkov.
multiprocessing.Process. Previously the child process would hang indefinitely. Reported in issue #230 by Lx Yu.
gevent.killall()accepts an arbitrary iterable for the greenlets to kill. Reported in issue #404 by Martin Bachwerk; seen in combination with older versions of simple-requests.
gevent.local.localobjects are now eligible for garbage collection as soon as the greenlet finishes running, matching the behaviour of the built-in
threading.local(when implemented natively). Reported in issue #387 by AusIV.
gevent.Greenlet.kill()) before it is actually started and switched to now prevents the greenlet from ever running, instead of raising an exception when it is later switched to. See issue #330 reported by Jonathan Kamens.
Add support for Python 3.3 and 3.4. Many people have contributed to this effort, including but not limited to Fantix King, hashstat, Elizabeth Myers, jander, Luke Woydziak, and others. See issue #38.
Add support for PyPy. See issue #248. Note that for best results, you’ll need a very recent PyPy build including CFFI 1.2.0.
Drop support for Python 2.5. Python 2.5 users can continue to use gevent 1.0.x.
gevent.subprocess.Popen to not ignore the
bufsize argument. Note
that this changes the (platform dependent) default, typically from
buffered to unbuffered. See pull request #542 by Romuald Brunet.
Upgraded c-ares to 1.10.0. See pull request #579 by Omer Katz.
configure script is now more strict about the
contents of environment variables such as
and they may have to be modified (for example,
CFLAGS is no
longer allowed to include
-I directives, which must instead be
timeout argument to
which now returns whether all items were waited for or not.
items passed to
__init__ as unfinished tasks, the same as if they were
Initial pull request #554 by DuLLSoN.
(Experimental.) Waiting on or getting results from greenlets that raised exceptions now usually raises the original traceback. This should assist things like Sentry to track the original problem. See issue #450 and issue #528 by Rodolfo and Eddi Linder and issue #240 by Erik Allik.
Upgrade to libev 4.20. See pull request #590 by Peter Renström.
gevent.baseserver.BaseServer to be printable when its
handle function is an instancemethod of itself. See pull request #501 by Joe
acquire method of
return True, supporting its use-case as an “infinite” or unbounded
semaphore providing no exclusion, and allowing the idiom
sem.acquire(): .... See pull request #544 by Mouad Benchchaoui.
subprocess by default in
imap_unordered now accept
multiple iterables like
itertools.imap. issue #565 reported by
gevent.server.StreamServer now deterministically
close the client socket when the request handler returns.
Previously, the socket was left at the mercies of the garbage
collector; under CPython 2.x this meant when the last reference went
away, which was usually, but not necessarily, when the request
handler returned, but under PyPy it was some arbitrary point in the
future and under CPython 3.x a ResourceWarning could be generated.
This was undocumented behaviour, and the client socket could be kept
open after the request handler returned either accidentally or intentionally.
pywsgi now ensures that headers can be
encoded in latin-1 (ISO-8859-1). This improves adherence to the HTTP
standard (and is necessary under Python 3). Under certain
conditions, previous versions could have allowed non-ISO-8859-1
headers to be sent, but their interpretation by a conforming
recipient is unknown; now, a UnicodeError will be raised. See issue #614.
Major and backward-incompatible changes:
misc: - gevent.joinall() method now accepts optional ‘count’ keyword. - gevent.fork() only calls reinit() in the child process now. - gevent.run() now returns False when exiting because of timeout or event (previous None). - Hub got a new method: destroy(). - Hub got a new property: threadpool.
ares.pyx: - Fixed issue #104: made ares_host_result pickable. Thanks to Shaun Cutts.
core: - Fixed issue #97: the timer watcher now calls ev_now_update() in start() and again() unless ‘update’ keyword is passed and set to False. - add set_syserr_cb() function; it’s used by gevent internally. - gevent now installs syserr callback using libev’s set_syserr_cb. This callback is called when libev encounters an error it cannot recover from. The default action is to print a message and abort. With the callback installed, a SystemError() is now raised in the main greenlet. - renamed ‘backend_fd’ property to ‘fileno()’ method. (not available if you build gevent against system libev) - added ‘asynccnt’ property (not available if you build gevent against system libev) - made loop.__repr__ output a bit more compact - the watchers check the arguments for validness now (previously invalid argument would crash libev). - The ‘async’ watcher now has send() method; - fixed time() function - libev has been upgraded to latest CVS version. - libev has been patched to use send()/recv() for evpipe on windows when libev_vfd.h is in effect
resolver_ares: - Slightly improved compatibility with stdlib’s socket in some error cases.
socket: - Fixed close() method not to reference any globals - Fixed issue #115: _dummy gets unexpected Timeout arg - Removed _fileobject used for python 2.4 compatibility in socket.py - Fixed issue #94: fallback to buffer if memoryview fails in _get_memory on python 2.7
monkey: - Removed patch_httplib() - Fixed issue #112: threading._sleep is not patched. Thanks to David LaBissoniere. - Added get_unpatched() function. However, it is slightly broken at the moment.
backdoor: - make ‘locals()’ not spew out __builtin__.__dict__ in backdoor - add optional banner argument to BackdoorServer
servers: - add server.DatagramServer; - StreamServer: ‘ssl_enabled’ is now a read-only property - servers no longer have ‘kill’ method; it has been renamed to ‘close’. - listeners can now be configured as strings, e.g. ‘:80’ or 80 - modify baseserver.BaseServer in such a way that makes it a good base class for both StreamServer and DatagramServer - BaseServer no longer accepts ‘backlog’ parameter. It is now done by StreamServer. - BaseServer implements start_accepting() and stop_accepting() methods - BaseServer now implements “temporarily stop accepting” strategy - BaseServer now has _do_read method which does everything except for actually calling accept()/recvfrom() - pre_start() method is renamed to init_socket() - renamed _stopped_event to _stop_event - ‘started’ is now a read-only property (which actually reports state of _stop_event) - post_stop() method is removed - close() now sets _stop_event(), thus setting ‘started’ to False, thus causing serve_forever() to exit - _tcp_listener() function is moved from baseserver.py to server.py - added ‘fatal_errors’ class attribute which is a tuple of all errnos that should kill the server
coros: - Semaphore: add _start_notify() method - Semaphore: avoid copying list of links; rawlink() no longer schedules notification
Added ‘ref’ property to all watchers. Settings it to False make watcher call ev_unref/ev_ref appropriately so that this watcher does not prevent loop.run()/hub.join()/run() from exiting. Made resolver_ares.Resolver use ‘ref’ property for internal watcher.
In all servers, method “kill” was renamed to “close”. The old name is available as deprecated alias.
Added a few properties to the loop: backend_fd, fdchangecnt, timercnt.
Upgraded c-ares to 1.7.5+patch.
Fixed getaddrinfo to return results in the order (::1, IPv4, IPv6).
Fixed getaddrinfo() to handle integer of string type. Thanks to kconor.
Fixed gethostbyname() to handle ‘’ (empty string).
Fixed getaddrinfo() to convert UnicodeEncodeError into error(‘Int or String expected’).
Fixed getaddrinfo() to uses the lowest 16 bits of passed port integer similar to built-in _socket.
Fixed getnameinfo() to call getaddrinfo() to process arguments similar to built-in _socket.
Fixed gethostbyaddr() to use getaddrinfo() to process arguments.
version_info is now a 5-tuple.
Added handle_system_error() method to Hub (used internally).
Fixed Hub’s run() method to never exit. This prevent inappropriate switches into parent greenlet.
Fixed Hub.join() to return True if Hub was already dead.
Added ‘event’ argument to Hub.join().
Added run() function to gevent top level package.
Fixed Greenlet.start() to exit silently if greenlet was already started rather than raising
Fixed Greenlet.start() not to schedule another switch if greenlet is already dead.
Fixed gevent.signal() to spawn Greenlet instead of raw greenlet. Also it’ll switch into the new greenlet immediately instead of scheduling additional callback.
Do monkey patch create_connection() as gevent’s version works better with gevent.socket.socket than the standard create_connection.
pywsgi: make sure we don’t try to read more requests if socket operation failed with EPIPE
pywsgi: if we failed to send the reply, change ‘status’ to socket error so that the logs mention the error.
Fixed a bug in gevent.queue.Channel class. (Thanks to Alexey Borzenkov)
gevent.queue.Channelif you need a channel.
gevent.corehas been rewritten and the interface is not compatible.
SystemErrornow kill the whole process instead of printing a traceback.
gevent.coremodule now wraps libev’s API and is not compatible with gevent 0.x.
signalworks now as expected.
gevent.queuemodule. It is equivalent to Queue(0) in gevent 0.x, which is deprecated now.
idle()function which blocks until the event loop is idle.
gevent.aresC extension which wraps c-ares and provides asynchronous DNS resolver.
gevent.resolver_aresmodule provides synchronous API on top of
DNS functions now use c-ares library rather than libevent-dns. This fixes a number of problems with name resolving:
The following functions were added to socket module - gethostbyname_ex - getnameinfo - gethostbyaddr - getfqdn
Removed undocumented bind_and_listen and tcp_listener
join()method which waits until the event loop exits or optional timeout expires.
wait()method which waits until a watcher has got an event.
handle_error()method which is called by all of gevent in case of unhandled exception.
print_exception()method which is called by handle_error to print the exception traceback.
The mod:gevent.pool module:
imap()methods now start yielding the results as soon as possible.
imap_unordered()no longer swallows an exception raised while iterating its argument.
WSGIServernow sets max_accept to 1 if wsgi.multiprocessing is set to True.
monkey.patch_module()function that monkey patches module using __implements__ list provided by gevent module. All of gevent modules that replace stdlib module now have __implements__ attribute.
Falsenow (previously it returned
gevent.local.localclass that implements copy semantics compatible with built-in
threading.local. Patch by Galfy Pundee.
StreamServerclass to catch
EAGAIN. This fixes lots of spurious tracebacks on Windows where these two constants are not the same. Patch by Alexey Borzenkov.
event_reinitonly in the child process; otherwise the process could hang when using libevent2. Patch by Alexander Boudkar.
TypeErrorthat occurred when
environ["wsgi.input"].readfunction was called with an integer argument.
threadingtoo, even if it’s already imported. Patch by Shaun Lindsay.
killall()functions used to hang if their argument contained duplicate greenlets.
pywsgi.WSGIServerreported “Connection reset by peer” if the client did not close the connection gracefully after the last request. Such errors are now ignored.
REQUEST_URIto environ. Patch by Andreas Blixt.
gevent.httplibused to break
HTTPSConnection. Patch by Nick Barkas.
create_connectionnow raises proper exception when
BaseServer.server_portattributes to handle the case of
AF_UNIXaddresses properly. Previously they assumed address is always a tuple.
AF_UNIXlisteners. The server now sets
environ["SERVER_PORT"]to empty string in such case.
pywsgi.WSGIServer) accept up to 100 connections per one readiness notification. This behaviour is controlled by
gevent.httplibthat rendered it unusable.
resolve_ipv6concurrently rather than sequentially in
gevent.httplib– experimental support for libevent-http client (issue #9). Thanks to Tommie Gannert, Örjan Persson.
gevent.wsgiwith libevent2 (issue #62).
pywsginot to use chunked transfer encoding in case of 304 and 204 responses as it creates a non-empty message body which is against RFC and causes some browsers to fail. Patch by Nicholas Piël.
AF_UNSPECproperly and resolve service names (issue #56). Thanks to Elizabeth Jennifer Myers.
socket.getaddrinfo()to handle international domain names.
sys.exc_infoset. Leaking is prevented by not preserving traceback at all and only keeping the value of the exception. Thanks to Ned Rockson.
SSLSocketproperly, without raising
SSLError(read operation timeout).
Hubon Python 2.4.
gevent.pywsgito make subclassing easier.
WSGIServerto explicitly close the socket after the last request. Patch by Ralf Schmitt.
pywsgi.WSGIHandlernot to add
CONTENT_TYPEto the environ dict when there’s no
Content-Typeheader in the request. Previously a default
text/plainwas added in such case.
Poolclass. Unlike previous “dummy” implementation this one starts yielding the results as soon as they are ready.
Queue. The main use case is the implementation of
BaseServer.startedproperty: it is now set to
kill. Previously it could become
Falsefor short period of times, because
StreamServercould stop accepting for a while in presence of errors and
StreamServer.startedwas defined as “whether the server is currently accepting”.
wsgi.WSGIServerto reply with 500 error immediatelly if the application raises an error (issue #58). Thanks to Jon Aslund.
monkey.patch_httplib()function which is disabled by default.
OverflowErrorthat could happen in
http_request.get_input_headers()return header names in lower case.
StreamServerto accept ciphers as an SSL argument.
build_exc --cython=option to
setup.py. Patch by Ralf Schmitt.
__dict__attribute is set or deleted.
gevent.sslmodule to fully match the functionality of
sslon Python 2.7.
raise_error=Trueproperly, it used to raise
TypeError(issue #36). Thanks to by David Hain.
gevent.pywsgito join multiple
Cookieheaders (issue #40).
longarguments in addition to
Falsewhen timeout expires instead of raising
AssertionError(issue #39). Patch by Erik Näslund.
JoinableQueue.join()to return immediatelly if queue is already empty (issue #45). Patch by Dmitry Chechik.
socket.shutdown()method to interrupt read/write operations on socket.
socket.connect_ex()method. Patch by Alexey Borzenkov.
gevent.socketimport all public items from stdlib
socketthat do not do I/O.
makefile()method on an SSL object would prevent the underlying socket from being closed until all objects get truely destroyed (Python issue #5238).
SSLSocket.__init__, only silence exceptions caused by the “socket not connected” condition.
SSLSocket.recvmethods to match the behavior of stdlib
ssl.SSLObjectto delete events used by other greenlets when closing the instance (issue #34).
longvalues as pool argument in addition to
webproxy.pyexample to be runnable under external WSGI server.
BackdoorServerclose the connection on
SystemExitand simplified the code.
ValueErrorwhen initialized with
setup.py --libeventto configure and make libevent if it’s not built already.
setuptoolsif present and add dependency on
StreamServerclass for easy implementing of TCP and SSL servers.
gevent.server. Contributed by Ralf Schmitt.
gevent.localmodule. Fixed issue #24. Thanks to Ted Suzman.
socket.sendall()to use buffer object to prevent string copies.
gevent.pywsgimuch more similar to each other.
Greenlet.kill()method and other kill* methods.
http.HTTPServerto match the interface of other servers.
spawn()method to block until there’s a free slot.
socket.wait_read()and similar. Use
Nonefrom now on, which is compatible with the previous versions.
StreamServerrather than from
Greenlet. This adds lots of new features and removes a few old ones.
core.http_connection. It is now used internally to detach the requests of the closed connections.
Group. The old name is currently available as an alias.
sys.platformto detect Windows rather than
getaddrinfo()used to handle the case when socktype or proto were equal to
0. Thanks to Randall Leeds.
BoundedSemaphoreclass to behave like
Event.wait()return internal flag instead of
ready()method as an alias for
serverand not to depend on
event. It is used by
detach()to detach input and output buffers too.
output_bufferstore and reuse the
bufferobject they create.
__str__()and meth:__repr__ to include spaces where needed.
httpclass no longer has
set_gencb(). Instead its contructor accepts handle which will be called on each request.
"Connection: close"header by default.
HTTPServernow derives from
baseserver.BaseServer. Thus its
start()method no longer accepts socket to listen on, it must be passed to the contructor.
Poolinstance. While the pool is full, the server replies with 503 error.
http_requestwhich will send 500 reply when deallocated if the user hasn’t send any.
Greenletinstead of raw greenlets. This means monkey patched thread will become
gevent.baseservermodule. All servers in gevent package are now derived from
IOErrorif passed a negative argument.
USE_LIBEVENT_?is no longer needed to build
backdoorwhen a client typed
greenletfailed with ImportError, keep the original error message, because sometimes the error originates in setuptools.
select.select()to return all the file descriptors signalled, not just the first one.
thread(and thus monkey patched threads) to spawn
Greenletinstances, rather than raw greenlets.
Thanks to Uriel Katz for
gevent.socket: Improved compatibility with stdlib’s socket:
timeout("timed out")rather than simply
socketmodule instead of creating a new object.
socket.send()and similar methods.
dns- with synchronous wrappers around libevent’s DNS API.
wsgimodule with the WSGI spec.
env["REMOTE_PORT"]into a string.
IOErrorif they failed.
getaddrinfo()to call the stdlib if the passed hostname has no dots.
getaddrinfo()to filter the results using socktype and proto arguments.
getnameinfo()as it didn’t quite match the stdlib interface. Use
dns.resolve_reverse()for reverse resolutions.
socket.connect_ex()to use cooperative
socket.dup()not to call underlying socket’s
dup()(which is not available on Windows) but to use Python’s reference counting similar to how the stdlib’s socket implements
socket‘s constructor. Passing the socket instance as first argument is no longer supported.
socket.sendall()to support flags argument.
socket.bind_and_listen(). The old name is still available as a deprecated alias.
gevent.socket. (Thanks to Matt Goodall for the original patch).
ssl(). (the old name is still available but deprecated)
GreenSocketalias for socket class.
gevent.oldsslmodule. It’s imported into
selectto clean up properly if event creation fails.
select.select()to what they are called in the stdlib.
libevent.h. They are not supported by vc90.
Waiternow stores the value if no one’s waiting for it.
testrunner.pyscript that replaces a bunch of small scripts that were used before.
is_secureattribute from sockets and ssl objects.
Greenletnot to print a traceback when a not-yet-started greenlet is killed.
backdoor()function and deprecated
__getattr__from socket class.
monkey.patch_socket()not to fail if
socket.ssl()is not present in
testpackage directly and run them in monkey patched environment.
environ['PATH_INFO']before passing to application.
ValueErrorto be raised incorrectly here.
gevent.socketnot to fail with
ImportErrorif Python was not built with ssl support.
select.select()function. Passing non-empty list of write descriptors used to cause this function to fail.
Contributed by Ludvig Ericson:
start_responseto recognize exc_info argument.
pool.Pool.join(): if timeout has expired it used to raise
Timeout; now it returns silently.
signal()to run the signal handler in a new greenlet; it was run in the
Timeout.start_new(): if passed a
Timeoutinstance, it now calls its
startmethod before returning it.
Queue.full()to be compatible with the standard
Queue. It tried to take into account the greenlets currently blocking on
putwhich was not useful and hard to reason about. Now it simply compares
qsizeto maxsize, which what the standard
Eventto behave exactly like the standard
Event.set()does not accept a parameter anymore; it’s now either set or not.
Event.getmethod is gone.
Event.set(); Event.clear()used to be a no-op; now it properly wakes up all the waiters.
AsyncResultbehaves exactly like before, but it does not inherit from
Eventanymore and does miss
GreenSocketis still available as an alias but will be removed in the future.
gevent.corenow includes wrappers for evbuffer, evdns, evhttp.
gevent.httpmodule based on libevent-http wrappers.
gevent.wsgimodule based on
gevent.coreand DNS functions to
gevent.socketmodule. Contributed by Jason Toffaletti..
setup.pyto select a libevent library to compile against. Check them out with
__all__to many modules that missed it.
Timeout API in a backward-incompatible way:
Timeout.__init__() does not start the timer immediately anymore;
Timeout.start() must be called explicitly.
A shortcut -
Timeout.start_new() - is provided that creates and starts
The implementation of
Greenlet is an improvement on
proc module, with these bugs fixed:
getcurrent()useless and using Procs as keys in dict impossible.
Greenletexecutes each link in a new greenlet by default, unless it is set up with
Greenlet, override its _run and __init__ methods.
gevent.event module with 2 classes:
Event is a drop-in replacement for
is an extension of
Event that supports exception passing via
core.write classes to
gevent.pywsgi: pulled Mike Barton’s eventlet patches that fix double content-length issue.
setup.py to search more places for system libevent installation.
This fixes 64bit CentOS 5.3 installation issues, hopefully covers other platforms
The following items were added to the gevent top level package:
The following items were marked as deprecated:
wrap_errorshelper was moved to
gevent.greenlet was split into a number of modules:
Hubclass and basic utilities, like
Hubis now a subclass of greenlet.
Greenletclass and helpers like
gevent.rawgreenletcontains the old “polling” versions of
killall(they do not need
linkfunctionality and work with any greenlet by polling their status and sleeping in a loop)
Thanks to Jason Toffaletti for reporting the installation issue and providing a test case for WSGI double content-length header bug.
gevent.queuemodule and made it 2.4-compatible.
PriorityQueueare implemented as well.
gevent.queuewill deprecate both
Timeoutto raise itself by default.
TimeoutErroris gone. Silent timeout is now created by passing
gevent.select.select()where it could silent the wrong timeout.
spawn_later()now avoid creating a closure and this decreases spawning time by 50%.
killall‘s wait argument was renamed to block. The polling is now implemented by
greenlet.joinallfunctions and it become more responsive, with gradual increase of sleep time.
shutdown()function, which blocks until libevent has finished dispatching the events.
event_delin core.pyx are now checked properly and
IOErroris raised if they have failed.
gevent.socket‘s implementation and fixed SSL bug reported on eventletdev by Cesar Alaniz as well as failures in
_fileobjectand is available on both
gevent.socketis still a work in progress.
core.active_eventclass that takes advantage of libevent’s
core.active_event(func)schedules func to be run in this event loop iteration as opposed to
core.timer(0, ...)which schedules an event to be run in the next iteration.
active_eventis now used throughout the library wherever
core.timer(0, ....)was previously used. This results in
spawn()being at least 20% faster compared to release 0.9.1 and twice as fast compared to eventlet. (The results are obtained with bench_spawn.py script in
killall()functions. If set to
True, it makes the function block until the greenlet(s) is actually dead. By default,
killall()are asynchronous, i.e. they don’t unschedule the current greenlet.
flags. It also has
__exit__now, so it can be used as a context manager.
callbacksignature has changed from
(event, fd, evtype)to
Hub‘s mainloop to never return successfully as this will screw up main greenlet’s
switch()call. Instead of returning it raises
reinit()function - wrapper for libevent’s
event_reinit. This function is a must have at least for daemons, as it fixes
epolland some others eventloops to work after
setup.pynot to depend on
Hubto recover silently after
event_dispatch()failures (I’ve seen this happen after
event_reinit()is called as necessary). The end result is that
fork()now works more reliably, as detected by
test_socketserver.py- it used to fail occasionally, now it does not.
gevent/__init__.pywas moved to
gevent/__init__.pyimports some of it back but not everything.
gevent.Timeout. The old name is available as an alias.
queue.Queue. Added test_queue.py from standard tests to check how good is
queue.Queuea replacement for a standard
Queue(not good at all, timeouts in
queue.Queue.put()don’t work yet)
monkeynow patches ssl module when on 2.6 (very limited support).
GreenSocketnow wraps a
_socketmodule rather than from
Started as eventlet 0.8.11 fork, with the intention to support only libevent as a backend. Compared to eventlet, this version has a much simpler API and implementation and a few severe bugs fixed, namely
write()on the same fd do not cancel one another.
GreenSocket.closemethod does not hang as it could with eventlet.
There’s a test in my repo of eventlet that reproduces both of them: http://bitbucket.org/denis/eventlet/src/tip/greentest/test__socket.py
Besides having less bugs and less code to care about the goals of the fork are: