gevent.lock.Semaphoresubclasses. If monkey-patched, this could also apply to
threading.Semaphoreobjects. Reported in issue #660 by Jay Oster.
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).
gevent.queue.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.
WSGIHandler) does a better job detecting and reporting potential encoding errors for headers and the status line during
start_responseas 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
signal.signalwork with the child watchers that are used by default. Also make
os.waitpidwork with a first argument of -1. 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_unorderedmethods of a pool 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.killraises 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.
successfulvalue to False when killing a greenlet before it ran with a non-default exception. Fixed in pull request #608 by Heungsub Lee.
os.waitpidto 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
waitpidfunction 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.
gevent.pywsgihandler is 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.
gevent.threadpool.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.
threadingmodule is 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.applynow raises any exception raised by the called function, the same as
Pooland the builtin
applyfunction. 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.sendallsupports 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 unimplemented, 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.iwaitno longer throws
LoopExitif the caller switches greenlets between return values. Reported and initial patch in pull request #467 by Alexey Borzenkov.
multiprocessing.Process. Previously the child process would hang indefinitely. Reported in issue #230 by Lx Yu.
gevent.killallaccepts 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.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.greenlet.joinall to not ignore
raise_error is False. See pull request #512 by Ivan Diao.
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
count argument to
gevent.greenlet.wait. See pull request #482 by
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 Ralf Schmitt for
pywsgi, a number of fixes for
wsgi, help with
server modules, improving setup.py and various other patches and suggestions.
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: