gevent
- Fixed #210: callbacks were not run for non-default loop (bug introduced in 1.0rc1).
- patch_all() no longer patches subprocess unless subprocess=True is passed.
- Fixed AttributeError in hub.Waiter.
- Fixed #181: make hidden imports visible to freezing tools like py2exe. Patch by Ralf Schmitt.
- Fixed #202: periodically yield when running callbacks (sleep(0) cannot block the event loop now).
- Fixed #204: os.tp_read/tp_write did not propogate errors to the caller.
- Fixed #217: do not set SO_REUSEADDR on Windows.
- Fixed bug in --module argument for gevent.monkey. Patch by Örjan Persson.
- Remove warning from threadpool.py about mixing fork() and threads.
- Cleaned up hub.py from code that was needed to support older greenlets. Patch by Saúl Ibarra Corretgé.
- Allow for explicit default loop creation via get_hub(default=True). Patch by Jan-Philip Gehrcke.
- Fixed hub.switch() not to touch stacktrace when switching. greenlet restores the exception information correctly since version 0.3.2. gevent now requires greenlet >= 0.3.2
- Added gevent.wait() and gevent.iwait(). This is like gevent.joinall() but supports more objects, including Greenlet, Event, Semaphore, Popen. Without arguments it waits for the event loop to finish (previously gevent.run() did that). gevent.run will be removed before final release and gevent.joinall() might be deprecated.
- Reimplemented loop.run_callback with a list and a single prepare watcher; this fixes the order of spawns and improves performance a little.
- Fixes Semaphore/Lock not to init hub in __init__, so that it's possible to have module-global locks without initializing the hub. This fixes monkey.patch_all() not to init the hub.
- New implementation of callbacks that executes them in the order they were added. core.loop.callback is removed.
- Fixed 2.5 compatibility.
- Fixed crash on Windows when request 'prev' and 'attr' attributes of 'stat' watcher. The attribute access still fails, but now with an exception.
- Added known_failures.txt that lists all the tests that fail. It can be used by testrunner.py via expected option. It's used when running the test suite in travis.
- Fixed socket, ssl and fileobject to not mask EBADF error - it is now propogated to the caller. Previously EBADF was converted to empty read/write. Thanks to Vitaly Kruglikov
- Removed gevent.event.waitall()
- Renamed FileObjectThreadPool -> FileObjectThread
- Greenlet: Fixed #143: greenlet links are now executed in the order they were added
- Synchronize access to FileObjectThread with Semaphore
- EINVAL is not longer handled in fileobject.
monkey:
- Fixed #178: disable monkey patch os.read/os.write
- Fixed monkey.patch_thread() to patch threading._DummyThread to avoid leak in threading._active. Original patch by Wil Tan.
- added Event=False argument to patch_all() and patch_thread
- added patch_sys() which patches stdin, stdout, stderr with FileObjectThread wrappers. Experimental / buggy.
- monkey patching everything no longer initializes the hub/event loop.
socket:
- create_connection: do not lookup IPv6 address if IPv6 is unsupported. Patch by Ralf Schmitt.
pywsgi:
- Fixed #86: bytearray is now supported. Original patch by Aaron Westendorf.
- Fixed #116: Multiline HTTP headers are now handled properly. Patch by Ralf Schmitt.
subprocess:
- Fixed Windows compatibility. The wait() method now also supports 'timeout' argument on Windows.
- Popen: Added rawlink() method, which makes Popen objects supported by gevent.wait(). Updated examples/processes.py
- Fixed #148: read from errpipe_read in small chunks, to avoid trigger EINVAL issue on Mac OS X. Patch by Vitaly Kruglikov
- Do os._exit() in "finally" section to avoid executing unrelated code. Patch by Vitaly Kruglikov.
resolver_ares:
- improve getaddrinfo: For string ports (e.g. "http") resolver_ares/getaddrinfo previously only checked either getservbyname(port, "tcp") or getservbyname(port, "udp"), but never both. It now checks both of them.
- gevent.ares.channel now accepts strings as arguments
- upgraded c-ares to cares-1_9_1-12-g805c736
- it is not possible to configure resolver_ares directly with environ, like GEVENTARES_SERVERS
os:
- Renamed threadpool_read/write to tp_read/write.
- Removed posix_read, posix_write.
- Added nb_read, nb_write, make_nonblocking.
hub:
- The system error is now raised immediatelly in main greenlet in all cases.
- Dropped support for old greenlet versions (need >= 0.3.2 now)
core:
- allow 'callback' property of watcher to be set to None. "del w.callback" no longer works.
- added missing 'noinotify' flag
Misc:
- gevent.thread: allocate_lock is now an alias for LockType/Semaphore. That way it does not fail when being used as class member.
- Updated greentest.py to start timeouts with ref=False.
- pool: remove unused get_values() function
- setup.py now recognizes GEVENTSETUP_EV_VERIFY env var which sets EV_VERIFY macro when compiling
- Added a few micro benchmarks
- stdlib tests that we care about are now included in greentest/2.x directories, so we don't depend on them being installed system-wide
- updated util/makedist.py
- the testrunner was completely rewritten.
- Added gevent.os module with 'read' and 'write' functions. Patch by Geert Jansen.
- Moved gevent.hub.fork to gevent.os module (it is still available as gevent.fork).
- Fixed issue #148: Made fileobject handle EINVAL, which is randomly raised by os.read/os.write on Mac OS X. Thanks to Mark Hingston.
- Fixed issue #150: gevent.fileobject.SocketAdapter.sendall() could needlessly wait for write event on the descriptor. Original patch by Mark Hingston.
- Fixed AttributeError in baseserver. In case of error, start() would call kill() which was renamed to close(). Thanks to Vitaly Kruglikov.
- New gevent.subprocess module
- New gevent.fileobject module
- Fixed ThreadPool to discard references of the objects passed to it (function, arguments) asap. Previously they could be stored for unlimited time until the thread gets a new job.
- Fixed #138: gevent.pool.Pool().imap_unordered hangs with an empty iterator. Thanks to exproxus.
- Fixed #127: ssl.py could raise TypeError in certain cases. Thanks to Johan Mjones.
- Fixed socket.makefile() to keep the timeout setting of the socket instance. Thanks to Colin Marc.
- Added 'copy()' method to queues.
- The 'nochild' event loop config option is removed. The install_sigchld offer more flexible way of enabling child watchers.
- core: all watchers except for 'child' now accept new 'priority' keyword argument
- gevent.Timeout accepts new arguments: 'ref' and 'priority'. The default priority for Timeout is -1.
- Hub.wait() uses Waiter now instead of raw switching
- Updated libev to the latest CVS version
- Made pywsgi to raise an AssertionError if non-zero content-length is passed to start_response(204/304) or if non-empty body is attempted to be written for 304/204 response
- Removed pywsgi feature to capitalize the passed headers.
- Fixed util/cythonpp.py to work on python3.2 (#123). Patch by Alexandre Kandalintsev.
- Added 'closed' readonly property to socket.
- Added 'ref' read/write property to socket.
- setup.py now parses CARES_EMBED and LIBEV_EMBED parameters, in addition to EMBED.
- gevent.reinit() and gevent.fork() only reinit hub if it was created and do not create it themselves
- Fixed setup.py not to add libev and c-ares to include dirs in non-embed mode. Patch by Ralf Schmitt.
- Renamed util/make_dist.py to util/makedist.py
- testrunner.py now saves more information about the system; the stat printing functionality is moved to a separate util/stat.py script.
Major and backward-incompatible changes:
- Made the threadpool-based resolver the default. To enable the ares-based resolver, set GEVENT_RESOLVER=ares env var.
- Added support for child watchers (not available on Windows).
- Libev loop now reaps all children by default.
- If NOCHILD flag is passed to the loop, child watchers and child reaping are disabled.
- Renamed gevent.coros to gevent.lock. The gevent.coros is still available but deprecated.
- Added 'stat' watchers to loop.
- The setup.py now recognizes gevent_embed env var. When set to "no", bundled c-ares and libev are ignored.
- Added optional 'ref' argument to sleep(). When ref=false, the watchers created by sleep() do not hold gevent.run() from exiting.
- ThreadPool now calls Hub.handle_error for exceptions in worker threads.
- ThreadPool got new method: apply_e.
- Added new extension module gevent._util and moved gevent.core.set_exc_info function there.
- Added new extension module gevent._semaphore. It contains Semaphore class which is imported by gevent.lock as gevent.lock.Semaphore. Providing Semaphore in extension module ensures that trace function set with settrace will not be called during __exit__. Thanks to Ralf Schmitt.
- It is now possible to kill or pre-spawn threads in ThreadPool by setting its 'size' property.
core:
- Make sure the default loop cannot be destroyed more than once, thus crashing the process.
- Make Hub.destroy() method not to destroy the default loop, unless destroy_loop is True. Non-default loops are still destroyed by default.
- loop: Removed properties from loop: fdchangecnt, timercnt, asynccnt.
- loop: Added properties: sigfd, origflags, origflags_int
- loop: The EVFLAG_NOENV is now always passed to libev. Thus LIBEV_FLAGS env variable is no longer checked. Use GEVENT_BACKEND.
Misc:
- Check that the argument of link() is callable. Raise TypeError when it's not.
- Fixed TypeError in baseserver when parsing an address.
- Pool: made add() and discard() usable by external users. Thanks to Danil Eremeev.
- When specifying a class to import, it is not possible to use format path/package.module.name
- pywsgi: Made sure format_request() does not fail if 'status' attribute is not set yet
- pywsgi: Added REMOTE_PORT variable to the environment.
Examples:
- portforwarder.py now shows how to use gevent.run() to implement graceful shutdown of a server.
- psycopg2_pool.py: Changed execute() to return rowcount.
- psycopg2_pool.py: Added fetchall() and fetchiter() methods.
Developer utilities:
- When building, CYTHON env variable can be used to specify Cython executable to use.
- util/make_dist.py now recongizes --fast and --revert options. Previous --rsync option is removed.
- Added util/winvbox.py which automates building/testing/making binaries on Windows VM.
- Fixed typos in exception handling code in testrunner.py
- Fixed patching unittest.runner on Python2.7. This caused the details of test cases run lost.
- Made testrunner.py kill the whole process group after test is done.
Backward-incompatible changes:
- Removed "link to greenlet" feature of Greenlet.
- If greenlet module older than 0.3.2 is used, then greenlet.GreenletExit.__bases__ is monkey patched to derive from BaseException and not Exception. That way gevent.GreenletExit is always derived from BaseException, regardless of installed greenlet version.
- Some code supporting Python 2.4 has been removed.
Release highlights:
- Added thread pool: gevent.threadpool.ThreadPool.
- Added thread pool-based resolver. Enable with GEVENT_RESOLVER=thread.
- Added UDP server: gevent.server.DatagramServer
- A "configure" is now run on libev. This fixes a problem of 'kqueue' not being available on Mac OS X.
- Gevent recognizes some environment variables now:
- GEVENT_BACKEND allows passing argument to loop, e.g. "GEVENT_BACKEND=select" for force select backend
- GEVENT_RESOLVER allows choosing resolver class.
- GEVENT_THREADPOOL allows choosing thread pool class.
- Added new examples: portforwarder, psycopg2_pool.py, threadpool.py, udp_server.py
- Fixed non-embedding build. To build against system libev, remove or rename 'libev' directory. To build against system c-ares, remove or rename 'c-ares'. Thanks to Örjan Persson.
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.
pywsgi: - Removed unused deprecated 'wfile' property from WSGIHandler - Fixed issue #92: raise IOError on truncated POST requests. - Fixed issue #93: do not sent multiple "100 continue" responses
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 AssertionError
.
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)
TODO: - gevent.http? - gevent.httplib? - gevent.wsgi? (Currently gevent/wsgi.py imports classes from gevent/pywsgi.py)
Backward-incompatible changes:
- Dropped support for Python 2.4.
- Queue(0) is now equivalent to an unbound queue and raises
DeprecationError
. Usegevent.queue.Channel
if you need a channel. - Deprecated ability to pass a greenlet instance to
Greenlet.link
,Greenlet.link_value
andGreenlet.link_exception
. - All of
gevent.core
has been rewritten and the interface is not compatible. SystemExit
andSystemError
now kill the whole process instead of printing a traceback.- Removed deprecated
util.lazy_property
property. - Removed
gevent.dns
module. - Removed deprecated gevent.sslold module
- Removed deprecated gevent.rawgreenlet module
- Removed deprecated name GreenletSet which used to be alias for
Group
.
Release highlights:
- The
gevent.core
module now wraps libev's API and is not compatible with gevent 0.x. - Added a concept of pluggable event loops. By default gevent.core.loop is used, which is a wrapper around libev.
- Added a concept of pluggable name resolvers. By default a resolver based on c-ares library is used.
- Added support for multiple OS threads, each new thread will get its own Hub instance with its own event loop.
- The release now includes and embeds the dependencies: libev and c-ares.
- The standard
signal
works now as expected. - The unhandled errors are now handled uniformely by Hub.handle_error function.
- Added
Channel
class togevent.queue
module. It is equivalent to Queue(0) in gevent 0.x, which is deprecated now. - Added method
peek
toQueue
class. - Added
idle
function which blocks until the event loop is idle. - Added a way to gracefully shutdown the application by waiting for all outstanding greenlets/servers/watchers:
Hub.join
. - Added new
gevent.ares
C extension which wraps c-ares and provides asynchronous DNS resolver. - Added new
gevent.resolver_ares
module provides synchronous API on top ofgevent.ares
.
The gevent.socket
module:
- DNS functions now use c-ares library rather than libevent-dns. This fixes a number of problems with name resolving:
- Issue #2: DNS resolver no longer breaks after fork(). You still need to call
gevent.fork
(os.fork is monkey patched with it if monkey.patch_all() was called). - DNS resolver no longer ignores /etc/resolv.conf and /etc/hosts.
- Issue #2: DNS resolver no longer breaks after fork(). You still need to call
- The following functions were added to socket module
- gethostbyname_ex
- getnameinfo
- gethostbyaddr
- getfqdn
- Removed undocumented bind_and_listen and tcp_listener
The Hub
object:
- Added
join
method which waits until the event loop exits or optional timeout expires. - Added
wait
method which waits until a watcher has got an event. - Added
handle_error
method which is called by all of gevent in case of unhandled exception. - Added
print_exception
method which is called by handle_error to print the exception traceback.
The Greenlet
objects:
- Added __nonzero__ implementation that returns True after greenlet was started until it's dead. Previously greenlet was False after start() until it was first switched to.
The mod:gevent.pool module:
- It is now possible to add raw greenlets to the pool.
- The
map
andimap
methods now start yielding the results as soon as possible. - The
imap_unordered
no longer swallows an exception raised while iterating its argument.
Miscellaneous:
- gevent.sleep(<negative value>) no longer raises an exception, instead it does sleep(0).
- Added method clear to internal Waiter class.
- Removed wait method from internal Waiter class.
- The
WSGIServer
now sets max_accept to 1 if wsgi.multiprocessing is set to True. - Added
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.
- Added
__copy__
method togevent.local.local
class that implements copy semantics compatible with built-inthreading.local
. Patch by Galfy Pundee. - Fixed
StreamServer
class to catchEWOULDBLOCK
rather thanEAGAIN
. This fixes lots of spurious tracebacks on Windows where these two constants are not the same. Patch by Alexey Borzenkov. - Fixed issue #65:
fork
now callsevent_reinit
only in the child process; otherwise the process could hang when using libevent2. Patch by Alexander Boudkar.
- Fixed build problem on Python 2.5
- Fixed
TypeError
that occurred whenenviron["wsgi.input"].read
function was called with an integer argument. - Fixed issue #63:
monkey.patch_thread
now patchesthreading
too, even if it's already imported. Patch by Shaun Lindsay. - Fixed issue #64:
joinall
andkillall
functions used to hang if their argument contained duplicate greenlets. - Fixed issue #69:
pywsgi.WSGIServer
reported "Connection reset by peer" if the client did not close the connection gracefully after the last request. Such errors are now ignored. - Fixed issue #67: Made
wsgi.WSGIServer
addREQUEST_URI
to environ. Patch by Andreas Blixt. - Fixed issue #71: monkey patching
httplib
withgevent.httplib
used to breakHTTPSConnection
. Patch by Nick Barkas. - Fixed issue #74:
create_connection <gevent.socket.create_connection>
now raises proper exception whengetaddrinfo
fails. - Fixed
BaseServer.__repr__
method,BaseServer.server_host
andBaseServer.server_port
attributes to handle the case ofAF_UNIX
addresses properly. Previously they assumed address is always a tuple. - Fixed
pywsgi.WSGIServer
to handleAF_UNIX
listeners. The server now setsenviron["SERVER_NAME"]
andenviron["SERVER_PORT"]
to empty string in such case. - Make
StreamServer
(and thuspywsgi.WSGIServer
) accept up to 100 connections per one readiness notification. This behaviour is controlled byStreamServer.max_accept
class attribute. - If bind fails, the servers now include the address that caused bind to fail in the error message.
- Fixed typo in
gevent.httplib
that rendered it unusable. - Removed unnecessary delay in
getaddrinfo <gevent.socket.getaddrinfo>
by callingresolve_ipv4
andresolve_ipv6
concurrently rather than sequentially inAF_UNSPEC
case.
- Added
gevent.httplib
-- experimental support for libevent-http client (issue #9). Thanks to Tommie Gannert, Örjan Persson. - Fixed crash on Mac OS X (issue #31). Patch by Alexey Borzenkov.
- Fixed compatiblity of
gevent.wsgi
with libevent2 (issue #62). - Fixed compilation issues with libevent2. Patch by Ralf Schmitt.
- Fixed
pywsgi
not 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. - Fixed
socket.getaddrinfo
to handleAF_UNSPEC
properly and resolve service names (issue #56). Thanks to Elizabeth Jennifer Myers. - Fixed
socket.getaddrinfo
to handle international domain names. - Fixed leaking of traceback object when switching out of greenlet with
sys.exc_info
set. Leaking is prevented by not preserving traceback at all and only keeping the value of the exception. Thanks to Ned Rockson. - Fixed
ssl.SSLSocket.unwrap
to shutdownSSLSocket
properly, without raisingSSLError(read operation timeout)
. - Fixed
TypeError
insideHub
on Python 2.4. - Made a number of internal improvements to
gevent.pywsgi
to make subclassing easier. - Changed
WSGIServer <pywsgi.WSGIServer>
to explicitly close the socket after the last request. Patch by Ralf Schmitt. - Fixed
pywsgi.WSGIHandler
not to addCONTENT_TYPE
to the environ dict when there's noContent-Type
header in the request. Previously a defaulttext/plain
was added in such case. - Added proper implementation of
imap_unordered <gevent.pool.Group.imap_unordered>
toPool
class. Unlike previous "dummy" implementation this one starts yielding the results as soon as they are ready. - Implemented iterator protocol in
Queue <gevent.queue.Queue>
. The main use case is the implementation ofPool.imap_unordered
. - Fixed
BaseServer.started
property: it is now set toTrue
afterstart <StreamServer.start>
untilstop <StreamServer.stop>
orkill <StreamServer.kill>
. Previously it could becomeFalse
for short period of times, becauseStreamServer
could stop accepting for a while in presence of errors andStreamServer.started
was defined as "whether the server is currently accepting". - Fixed
wsgi.WSGIServer
to reply with 500 error immediatelly if the application raises an error (issue #58). Thanks to Jon Aslund. - Added
monkey.patch_httplib
function which is disabled by default. - Added httplib parameter to
monkey.patch_all
(defaults toFalse
). - Added
write <core.buffer.write>
method tocore.buffer
. - Fixed
OverflowError
that could happen incore.event.__str__
. - Made
http_request.get_input_headers
return header names in lower case. - Fixed
StreamServer
to accept ciphers as an SSL argument. - Added
build_exc --cython=
option tosetup.py
. Patch by Ralf Schmitt. - Updated
local <gevent.local.local>
to raiseAttributeError
if__dict__
attribute is set or deleted.
Release highlights:
- Fixed
monkey
to patchsocket.create_connection <gevent.socket.create_connection>
. - Updated
gevent.ssl
module to fully match the functionality ofssl
on Python 2.7. - Fixed
Group.join
to handleraise_error=True
properly, it used to raiseTypeError
(issue #36). Thanks to by David Hain. - Fixed
gevent.wsgi
andgevent.pywsgi
to join multipleCookie
headers (issue #40). - Fixed
select <gevent.select.select>
to recognizelong
arguments in addition toint
. - Fixed
Semaphore.acquire
to returnFalse
when timeout expires instead of raisingAssertionError
(issue #39). Patch by Erik Näslund. - Fixed
JoinableQueue.join
to return immediatelly if queue is already empty (issue #45). Patch by Dmitry Chechik. - Deprecated
gevent.sslold
module.
gevent.socket
module:
- Overrode
socket.shutdown
method to interrupt read/write operations on socket. - Fixed possible
NameError
insocket.connect_ex
method. Patch by Alexey Borzenkov. - Fixed socket leak in
create_connection
function. - Made
gevent.socket
import all public items from stdlibsocket
that do not do I/O.
gevent.ssl
module:
- Imported a number of patches from stdlib by Antoine Pitrou:
- Calling
makefile
method on an SSL object would prevent the underlying socket from being closed until all objects get truely destroyed (Python issue #5238). - SSL handshake would ignore the socket timeout and block indefinitely if the other end didn't respond (Python issue #5103).
- When calling
getpeername
inSSLSocket.__init__
, only silence exceptions caused by the "socket not connected" condition.
- Calling
- Added support for ciphers argument.
- Updated
SSLSocket.send
andSSLSocket.recv
methods to match the behavior of stdlibssl
better. - Fixed
ssl.SSLObject
to delete events used by other greenlets when closing the instance (issue #34).
Miscellaneous:
- Made
BaseServer
acceptlong
values as pool argument in addition toint
. - Made
http._requests
attribute public. - Updated webchat example to use file on disk rather than in-memory sqlite database to avoid
OperationalError
. - Fixed
webproxy.py
example to be runnable under external WSGI server. - Fixed bogus failure in
test__exc_info.py
. - Added new test to check PEP8 conformance:
xtest_pep8.py
. - Fixed
BackdoorServer
close the connection onSystemExit
and simplified the code. - Made
Pool
raiseValueError
when initialized withsize=0
. - Updated
setup.py --libevent
to configure and make libevent if it's not built already. - Updated
setup.py
to usesetuptools
if present and add dependency ongreenlet
. - Fixed doc/mysphinxext.py to work with Sphinx 1. Thanks by Örjan Persson.
Release highlights:
- Added
gevent.server
module withStreamServer
class for easy implementing of TCP and SSL servers. - Added
gevent.baseserver
module withBaseServer
class. - Added new implementation of
gevent.pywsgi
based ongevent.server
. Contributed by Ralf Schmitt. - Added
gevent.local
module. Fixed issue #24. Thanks to Ted Suzman. - Fixed a number of bugs in
gevent.wsgi
module. - Fixed issue #26: closing a socket now interrupts all pending read/write operations on it.
- Implemented workaround that prevents greenlets from leaking
exc_info
. - Fixed
socket.sendall
to use buffer object to prevent string copies. - Made the interfaces of
gevent.wsgi
andgevent.pywsgi
much more similar to each other. - Fixed compilation on Windows with libevent-2.
- Improved Windows compatibility. Fixed issue #30. Thanks to Luigi Pugnetti.
- Fixed compatibility with Python 2.7.
Backward-incompatible changes:
- Blocking is now the default behaviour for the
Greenlet.kill
method and other kill* methods. - Changed the inteface of
http.HTTPServer
to match the interface of other servers. - Changed
Pool
'sspawn
method to block until there's a free slot. - Removed deprecated
backdoor.backdoor_server
function. - Removed deprecated functions in
socket
module:socket_bind_and_listen
set_reuse_addr
connect_tcp
tcp_server
- Removed deprecated
socket.fd
property. - Deprecated use of negative numbers to indicate infinite timeout in
core.event.add
andsocket.wait_read
and similar. UseNone
from now on, which is compatible with the previous versions. - Derived
backdoor.BackdoorServer
fromStreamServer
rather than fromGreenlet
. This adds lots of new features and removes a few old ones. - Removed non-standard
balance
property fromSemaphore
. - Removed
start
,set_cb
andset_gencb
fromcore.http
. - Removed
set_closecb
fromcore.http_connection
. It is now used internally to detach the requests of the closed connections. - Deprecated
rawgreenlet
module. - Deprecated
util.lazy_property
. - Renamed
GreenletSet
toGroup
. The old name is currently available as an alias.
gevent.socket
module:
- Fixed issues #26 and #34: closing the socket while reading/writing/connecting is now safe. Thanks to Cyril Bay.
- Imported
getfqdn
fromsocket
module. - The module now uses
sys.platform
to detect Windows rather thanplatform
module. - Fixed issue #27:
getaddrinfo
used to handle the case when socktype or proto were equal to0
. Thanks to Randall Leeds.
gevent.coros
module:
- Added
RLock
class. - Added
DummySemaphore
class. - Fixed
BoundedSemaphore
class to behave likethreading.BoundedSemaphore
behaves.
gevent.event
module:
- Made
Event.wait
return internal flag instead ofNone
. - Made
AsyncResult.wait
return itsvalue
instead ofNone
. - Added
ready
method as an alias foris_set
.
gevent.wsgi
module:
- Removed
wsgi.buffer_proxy
.
gevent.pywsgi
module:
- Rewritten to use
server
and not to depend onBaseHTTPServer
. - Changed the interface to match
wsgi
module. Removedserver
function, addServer
class, addedWSGIServer
class. - Renamed
HttpProtocol
toWSGIHandler
. - Fixed compatibility with webob by allowing an optional argument to
readline
.
gevent.core
module:
- Fixed reference leaks in
event
class. - Avoid Python name lookups when accessing EV* constants from Cython code. Patch by Daniele Varrazzo.
- Added persist argument to
read_event
,write_event
andreadwrite_event
. - Made all of the event loop callbacks clear the exception info before exiting.
- Added
flags_str
property toevent
. It is used by__str__
and__repr__
. buffer <core.buffer>
:- Added
detach
method. - Implemented iterator protocol.
- Fixed
readline
andreadlines
methods.
- Added
http_request
:- Fixed
detach
to detach input and output buffers too. - Changed the response to send 500 error upon deallocation, if no response was sent by the user.
- Made
input_buffer
andoutput_buffer
store and reuse thebuffer
object they create. - Fixed
__str__
and meth:__repr__ to include spaces where needed. http
class no longer hasset_cb
andset_gencb
. Instead its contructor accepts handle which will be called on each request.
- Fixed
gevent.http
and gevent.wsgi
modules:
- Made
HTTPServer
use"Connection: close"
header by default. - Class
HTTPServer
now derives frombaseserver.BaseServer
. Thus itsstart
method no longer accepts socket to listen on, it must be passed to the contructor. - The spawn argument now accepts a
Pool
instance. While the pool is full, the server replies with 503 error. - The server no longer links to the greenlets it spawns to detect errors. Instead, it relies on
http_request
which will send 500 reply when deallocated if the user hasn't send any.
Miscellaneous:
- Changed
gevent.thread
to useGreenlet
instead of raw greenlets. This means monkey patched thread will becomeGreenlet
too. - Added
started
property toGreenlet
. - Put common server code in
gevent.baseserver
module. All servers in gevent package are now derived fromBaseServer
. - Fixed issue #20:
sleep
now raisesIOError
if passed a negative argument. - Remove the code related to finding out libevent version from setup.py as macro
USE_LIBEVENT_?
is no longer needed to buildgevent.core
. - Increased default backlog in all servers (from 5 to 256). Thanks to Nicholas Piël.
- Fixed doc/conf.py to work in Python older than 2.6. Thanks to Örjan Persson.
- Silented SystemError raised in
backdoor
when a client typedquit()
. - If importing
greenlet
failed with ImportError, keep the original error message, because sometimes the error originates in setuptools. - Changed
select.select
to return all the file descriptors signalled, not just the first one. - Made
thread
(and thus monkey patched threads) to spawnGreenlet
instances, rather than raw greenlets.
Examples:
- Updated echoserver.py to use
StreamServer
. - Added geventsendfile.py.
- Added wsgiserver_ssl.py.
Thanks to Ralf Schmitt for pywsgi
, a number of fixes for wsgi
, help with baseserver
and server
modules, improving setup.py and various other patches and suggestions.
Thanks to Uriel Katz for pywsgi
patches.
- Fixed http server to put the listening socket into a non-blocking mode. Contributed by Ralf Schmitt.
- Removed a symlink from the distribution (that causes pip to fail). Thanks to Brad Clements for reporting it.
- setup.py: automatically create symlink from
build/lib.../gevent/core.so
togevent/core.so
. gevent.socket
: Improved compatibility with stdlib's socket:- Fixed
socket <gevent.socket.socket>
to raisetimeout("timed out")
rather than simplytimeout
. - Imported
_GLOBAL_DEFAULT_TIMEOUT
from standardsocket
module instead of creating a new object.
- Fixed
Release highlights:
- Added
gevent.ssl
module. - Fixed Windows compatibility (experimental).
- Improved performance of
socket.recv
,socket.send
and similar methods. - Added a new module -
dns
- with synchronous wrappers around libevent's DNS API. - Added
core.readwrite_event
andsocket.wait_readwrite
functions. - Fixed several incompatibilities of
wsgi
module with the WSGI spec. - Deprecated
pywsgi
module.
gevent.wsgi
module:
- Made
env["REMOTE_PORT"]
into a string. - Fixed the server to close the iterator returned by the application.
- Made
wsgi.input
object iterable.
gevent.core
module:
- Made DNS functions no longer accept/return IP addresses in dots-and-numbers format. They work with packed IPs now.
- Made DNS functions no longer accept additional arguments to pass to the callback.
- Fixed DNS functions to check the return value of the libevent functions and raise
IOError
if they failed. - Added
core.dns_err_to_string
. - Made core.event.cancel not to raise if event_del reports an error. instead, the return code is passed to the caller.
- Fixed minor issue in string representation of the events.
gevent.socket
module:
- Fixed bug in socket.accept. It could return unwrapped socket instance if socket's timeout is 0.
- Fixed socket.sendall implementation never to call underlying socket's sendall.
- Fixed
gethostbyname
andgetaddrinfo
to call the stdlib if the passed hostname has no dots. - Fixed
getaddrinfo
to filter the results using socktype and proto arguments. - Removed
getnameinfo
as it didn't quite match the stdlib interface. Usedns.resolve_reverse
for reverse resolutions. - Fixed
socket.connect_ex
to use cooperativegethostbyname
. - Fixed
socket.dup
not to call underlying socket'sdup
(which is not available on Windows) but to use Python's reference counting similar to how the stdlib's socket implementsdup
- Added _sock argument to
socket
's constructor. Passing the socket instance as first argument is no longer supported. - Fixed
socket.connect
to ignoreWSAEINVAL
on Windows. - Fixed
socket.connect
to usewait_readwrite
instead ofwait_write
. - Fixed
socket.connect
to consultSO_ERROR
. - Fixed
socket.send
andsocket.sendall
to support flags argument. - Renamed
socket_bind_and_listen
tosocket.bind_and_listen
. The old name is still available as a deprecated alias. - The underlying socket object is now stored as
_sock
property. - Imported the constants and some utility functions from stdlib's
socket
intogevent.socket
. (Thanks to Matt Goodall for the original patch). - Renamed
wrap_ssl
tossl
. (the old name is still available but deprecated) - Deprecated
connect_tcp
andtcp_server
. - Added
sslerror
tosocket.__all__
. - Removed
GreenSocket
alias for socket class. - Moved PyOpenSSL-based implementation of
socket.ssl
intogevent.oldssl
module. It's imported intogevent.socket
if importinggevent.ssl
fails.
Miscellaneous:
- Fixed Greenlet.spawn_link* and GreenletSet.spawn_link* classmethods not to assume anything about their arguments. (Thanks to Marcus Cavanaugh for pointing that out).
- Fixed
select <gevent.select.select>
to clean up properly if event creation fails. - Fixed
select <gevent.select.select>
to raiseselect.error
instead ofIOError
. - Fixed setup.py to proceed with compilation even if libevent version cannot be determined. 1.x.x is assumed in this case.
- Fixed compatibility of .pyx files with Cython 0.12.0.
- Renamed arguments for
select.select
to what they are called in the stdlib. - Removed internal function
getLinkedCompleted
fromgevent.greenlet
. - Remove
#warning
directives fromlibevent.h
. They are not supported by vc90. - Removed some deprecated stuff from
coros
. - Internal class
Waiter <gevent.hub.Waiter>
now stores the value if no one's waiting for it. - Added
testrunner.py
script that replaces a bunch of small scripts that were used before. - Removed
is_secure
attribute from sockets and ssl objects. - Made
Greenlet
not to print a traceback when a not-yet-started greenlet is killed. - Added
BackdoorServer
class tobackdoor
. Removedbackdoor
function and deprecatedbackdoor_server
function. - Removed
__getattr__
from socket class. - Fixed
monkey.patch_socket
not to fail ifsocket.ssl
is not present ingevent.socket
. - Added
monkey.patch_ssl
. - Added aggressive argument to
monkey.patch_all
. - Tests from stdlib no longer included in greentest package. Instead, there are number of stubs that import those tests from
test
package directly and run them in monkey patched environment. - Added examples/process.py by Marcus Cavanaugh.
- Fixed
wsgi
to unquoteenviron['PATH_INFO']
before passing to application. - Added
SERVER_SOFTWARE
variable towsgi
environ. - Fixed bug in
JoinableQueue.task_done
that causedValueError
to be raised incorrectly here. - Fixed
gevent.socket
not to fail withImportError
if Python was not built with ssl support.
- Fixed bug in
select.select
function. Passing non-empty list of write descriptors used to cause this function to fail. - Changed setup.py to go ahead with the compilation even if the actual version of libevent cannot be determined (version 1.x.x is assumed in that case).
Contributed by Ludvig Ericson:
- Fixed
wsgi
'sstart_response
to recognize exc_info argument. - Fixed setup.py to look for libevent.dylib rather than .so on Darwin platforms.
- Fixed timeout bug in
joinall
,Greenlet.join
,pool.Pool.join
: if timeout has expired it used to raiseTimeout
; now it returns silently. - Fixed
signal
to run the signal handler in a new greenlet; it was run in theHub
greenlet before. - Fixed
Timeout.start_new
: if passed aTimeout
instance, it now calls itsstart <Timeout.start>
method before returning it. - Fixed
gevent.monkey
to patchthreading.local
properly. - Fixed
Queue.empty
andQueue.full
to be compatible with the standardQueue
. It tried to take into account the greenlets currently blocking onget <Queue.get>
/put <Queue.put>
which was not useful and hard to reason about. Now it simply comparesqsize <Queue.qsize>
to maxsize, which what the standardQueue
does too. - Fixed
Event
to behave exactly like the standardthreading.Event
:Event.set
does not accept a parameter anymore; it's now either set or not.Event.get
method is gone.Event.set(); Event.clear()
used to be a no-op; now it properly wakes up all the waiters.AsyncResult
behaves exactly like before, but it does not inherit fromEvent
anymore and does missclear()
method.
- Renamed internal helpers
socket.wait_reader
/socket.wait_writer
tosocket.wait_read
/socket.wait_write
. - Renamed
gevent.socket.GreenSocket
togevent.socket.socket
.GreenSocket
is still available as an alias but will be removed in the future. gevent.core
now includes wrappers for evbuffer, evdns, evhttp.- Renamed the old
gevent.wsgi
togevent.pywsgi
. - Added a new HTTP server
gevent.http
module based on libevent-http wrappers. - Added a new WSGI server
gevent.wsgi
module based ongevent.http
. - Added evdns wrappers to
gevent.core
and DNS functions togevent.socket
module. Contributed by Jason Toffaletti.. - Added a few a few options to
setup.py
to select a libevent library to compile against. Check them out withsetup.py -h
. - Added
__all__
to many modules that missed it. - Converted the docstrings and the changelog to sphinx/rst markup.
- Added sphinx/rst documentation. It is available online at http://www.gevent.org.
- Changed
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 aTimeout
. - Added
gevent.Greenlet
class which is a subclass of greenlet that adds a few useful methodsjoin <Greenlet.join>
/get <Greenlet.get>
/kill <Greenlet.kill>
/link <Greenlet.link>
. spawn
now returnsGreenlet
instance. The oldspawn
, which returnspy.magic.greenlet
instance, can be still accessed asspawn_raw
.Note
The implementation of
Greenlet
is an improvement onproc
module, with these bugs fixed:- Proc was not a subclass of greenlet which makes
getcurrent
useless and using Procs as keys in dict impossible. - Proc executes links sequentially, so one could block the rest from being executed.
Greenlet
executes each link in a new greenlet by default, unless it is set up withGreenlet.rawlink
method. - Proc cannot be easily subclassed. To subclass
Greenlet
, override its _run and __init__ methods.
- Proc was not a subclass of greenlet which makes
- Added
pool.Pool
class with the methods compatible to the standardmultiprocessing.pool
:apply <Pool.apply>
,map <Pool.map>
and others. It also hasspawn <Pool.spawn>
method which is always async and returns aGreenlet
instance. - Added
gevent.event
module with 2 classes:Event
andAsyncResult
.Event
is a drop-in replacement forthreading.Event
, supportingset <Event.set>
/wait <Event.wait>
/get
methods.AsyncResult
is an extension ofEvent
that supports exception passing viaset_exception <AsyncResult.set_exception>
method. - Added
queue.JoinableQueue
class withtask_done <queue.JoinableQueue.task_done>
andjoin <queue.JoinableQueue.join>
methods. - Renamed
core.read
andcore.write
classes tocore.read_event
andcore.write_event
. gevent.pywsgi
: pulled Mike Barton's eventlet patches that fix double content-length issue.- Fixed
setup.py
to search more places for system libevent installation. This fixes 64bit CentOS 5.3 installation issues, hopefully covers other platforms as well.
The following items were added to the gevent top level package:
spawn_link
spawn_link_value
spawn_link_exception
spawn_raw
joinall
killall
Greenlet
GreenletExit
core
The following items were marked as deprecated:
- gevent.proc module (
wrap_errors
helper was moved toutil
module) - gevent.coros.event
- gevent.coros.Queue and gevent.coros.Channel
Internally, gevent.greenlet
was split into a number of modules:
gevent.hub
providesHub
class and basic utilities, likesleep
;Hub
is now a subclass of greenlet.gevent.timeout
providesTimeout
andwith_timeout
;gevent.greenlet
providesGreenlet
class and helpers likejoinall
andkillall
.gevent.rawgreenlet
contains the old "polling" versions ofjoinall <rawgreenlet.joinall>
andkillall <rawgreenlet.killall>
(they do not needlink <Greenlet.link>
functionality 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.
- Fixed all known bugs in the
gevent.queue
module and made it 2.4-compatible.LifoQueue
andPriorityQueue
are implemented as well.gevent.queue
will deprecate bothcoros.Queue
andcoros.Channel
. - Fixed
Timeout
to raise itself by default.TimeoutError
is gone. Silent timeout is now created by passingFalse
instead ofNone
. - Fixed bug in
gevent.select.select
where it could silent the wrong timeout. spawn
andspawn_later
now avoid creating a closure and this decreases spawning time by 50%.kill
's andkillall
's wait argument was renamed to block. The polling is now implemented bygreenlet.join
andgreenlet.joinall
functions and it become more responsive, with gradual increase of sleep time.- Renamed
proc.RunningProcSet
toproc.ProcSet
. - Added
shutdown
function, which blocks until libevent has finished dispatching the events. - The return value of
event_add
andevent_del
in core.pyx are now checked properly andIOError
is raised if they have failed. - Fixed backdoor.py, accidentally broken in the previous release.
- Simplified
gevent.socket
's implementation and fixed SSL bug reported on eventletdev by Cesar Alaniz as well as failures intest_socket_ssl.py
. - Removed
GreenSocket.makeGreenFile
; Usesocket.socket.makefile
that returns_fileobject
and is available on bothGreenSocket <gevent.socket.socket>
andGreenSSL <gevent.socket.GreenSSL>
. Thegevent.socket
is still a work in progress. - Added new
core.active_event
class that takes advantage of libevent'sevent_active
function.core.active_event(func)
schedules func to be run in this event loop iteration as opposed tocore.timer(0, ...)
which schedules an event to be run in the next iteration.active_event
is now used throughout the library wherevercore.timer(0, ....)
was previously used. This results inspawn
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 ingreentest/
directory) - Added boolean parameter wait to
kill
andkillall
functions. If set toTrue
, it makes the function block until the greenlet(s) is actually dead. By default,kill
andkillall
are asynchronous, i.e. they don't unschedule the current greenlet. - Added a few new properties to
gevent.core.event
:fd <event.fd>
,events <event.events>
,events_str <event.events_str>
andflags <event.flags>
. It also has__enter__ <event.__enter__>
and__exit__ <event.__exit__>
now, so it can be used as a context manager.event
'scallback <event.callback>
signature has changed from(event, fd, evtype)
to(event, evtype)
. - Fixed
Hub
's mainloop to never return successfully as this will screw up main greenlet'sswitch()
call. Instead of returning it raisesDispatchExit
. - Added
reinit
function - wrapper for libevent'sevent_reinit
. This function is a must have at least for daemons, as it fixesepoll
and some others eventloops to work afterfork
. - Trying to use gevent in another thread will now raise an exception immediately, since it's not implemented.
- Added a few more convenience methods
spawn_link[exception/value]
toproc.RunningProcSet
. - Fixed
setup.py
not to depend onsetuptools
. - Removed
gevent.timeout
. Usegevent.Timeout
.
- Fixed compilation with libevent-1.3. Thanks to Litao Wei for reporting the problem.
- Fixed
Hub
to recover silently afterevent_dispatch()
failures (I've seen this happen afterfork
even thoughevent_reinit()
is called as necessary). The end result is thatfork
now works more reliably, as detected bytest_socketserver.py
- it used to fail occasionally, now it does not. - Reorganized the package, most of the stuff from
gevent/__init__.py
was moved togevent/greenlet.py
.gevent/__init__.py
imports some of it back but not everything. - Renamed
gevent.timeout
togevent.Timeout
. The old name is available as an alias. - Fixed a few bugs in
queue.Queue
. Added test_queue.py from standard tests to check how good isqueue.Queue
a replacement for a standardQueue
(not good at all, timeouts inqueue.Queue.put
don't work yet) monkey
now patches ssl module when on 2.6 (very limited support).- Improved compatibility with Python 2.6 and Python 2.4.
- Greenlet installed from PyPI (without py.magic prefix) is properly recognized now.
- core.pyx was accidentally left out of the source package, it's included now.
GreenSocket <socket.socket>
now wraps asocket
object from_socket
module rather than fromsocket
.
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
- Full duplex in sockets, i.e.
read()
andwrite()
on the same fd do not cancel one another. - The
GreenSocket.close <socket.socket.close>
method 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:
- Piggy-back on libevent as much as possible (use its http and dns code).
- Use the interfaces and conventions from the standard Python library where possible.