gevent.lock.RLock.acquire
accept the timeout parameter.AttributeError
when wrapping gevent’s FileObject
around an opened text stream. Reported in issue #1542 by
dmrlawson.Upgrade libev from 4.25 to 4.31 and update its embedded
config.guess
to the latest. See issue #1504.
Important
libev, when built with EV_VERIFY >= 2
, now performs
verification of file descriptors when IO watchers are started
and when they are stopped. If you first close a file descriptor
and only then stop an associated watcher, libev will abort the
process.
Using the standard gevent socket and file objects handles this automatically, but if you’re using the IO watchers directly, you’ll need to watch out for this.
The binary wheels gevent distributes do not set EV_VERIFY
and don’t have this issue.
Make libuv and libev use the Python memory allocators. This assists with debugging. The event libraries allocate small amounts of memory at startup. The allocation functions have to take the GIL, but because of the limited amount of actual allocation that gets done this is not expected to be a bottleneck.
Update the bundled tblib
library to the unreleased 1.7.0
version. The only change is to add more attributes to Frame
and Code
objects for pytest compatibility. See pull request #1541.
gevent.signal
. This served as both
a deprecated alias of gevent.signal_handler
and the module
gevent.signal
. This made it confusing to humans and static
analysis tools alike. The alias was deprecated since gevent 1.1b4.
See issue #1596.gevent.subprocess.Popen.communicate
raise exceptions raised
by reading from the process, like the standard library. In
particular, under Python 3, if the process output is being decoded
as text, this can now raise UnicodeDecodeError
. Reported in
issue #1510 by Ofer Koren.gevent.subprocess.Popen.communicate
be more careful about
closing files. Previously if a timeout error happened, a second call
to communicate
might not close the pipe.gevent.contextvars
, a cooperative version of contextvars
.
This is available to all Python versions. On Python 3.7 and above,
where contextvars
is a standard library module, it is
monkey-patched by default. See issue #1407.selectors.PollSelector
as the selectors.DefaultSelector
after monkey-patching if select.poll
was defined. Previously,
gevent replaced it with selectors.SelectSelector
, which has a
different set of limitations (e.g., on certain platforms such as
glibc Linux, it has a hardcoded limitation of only working with file
descriptors < 1024). See issue #1466 reported by Sam Wong.threading.Lock
and threading.RLock
objects as spin locks by making them call sleep(0)
if they
failed to acquire the lock in a non-blocking call. This lets other
callbacks run to release the lock, simulating preemptive threading.
Using spin locks is not recommended, but may have been done in code
written for threads, especially on Python 3. See issue #1464.rawlink
of Semaphore,
Event, and AsyncResult now always remove the link object when
calling it, so unlink
can sometimes be optimized out. See
issue #1487.gevent.pywsgi
support Connection: keep-alive
in
HTTP/1.0. Based on pull request #1331 by tanchuhan.gevent.idle()
when using libuv. See
issue #1489.ThreadPool
consistently raise InvalidThreadUseError
when spawn
is called from a thread different than the thread
that created the threadpool. This has never been allowed, but was
inconsistently enforced. On gevent 1.3 and before, this would always
raise “greenlet error: invalid thread switch,” or LoopExit
. On
gevent 1.4, it could raise LoopExit
, depending on the number
of tasks, but still, calling it from a different thread was likely
to corrupt libev or libuv internals.python
-m gevent.monkey
. Previously it would use greenlets instead of
native threads. See issue #1484.handle_error
function was poorly customized, for example. See issue #1482gevent.killall
stop greenlets from running that hadn’t been
run yet. This make it consistent with Greenlet.kill()
. See
issue #1473 reported by kochelmonster.gevent.spawn_raw
set the loop
attribute on returned
greenlets. This lets them work with more gevent APIs, notably
gevent.killall()
. They already had dictionaries, but this may
make them slightly larger, depending on platform (on CPython 2.7
through 3.6 there is no apparent difference for one attribute but on
CPython 3.7 and 3.8 dictionaries are initially empty and only
allocate space once an attribute is added; they’re still smaller
than on earlier versions though).Caution
There may be breaking changes here for applications that relied on the old behaviour. The old behaviour was under specified and inconsistent and really only worked consistently with ‘wb’ and ‘rb’ modes, so most applications shouldn’t be affected.
FileObjectPosix
, FileObjectThread
) now
consistently support text and binary modes. If neither ‘b’ nor ‘t’ is given
in the mode, they will read and write native strings. If ‘t’ is
given, they will always work with unicode strings, and ‘b’ will
always work with byte strings. (FileObjectPosix
already worked this
way.) See issue #1441.FileObjectPosix
changed from rb
to simply
r
, for consistency with the other file objects and the standard
open
and io.open()
functions.FileObjectPosix
improperly being used from multiple
greenlets. Previously this was hidden by forcing buffering, which
raised RuntimeError
.--module
option to gevent.monkey
allowing to run a Python
module rather than a script. See pull request #1440.SSLSocket.verify_client_post_handshake()
when available.nlink_t
for
st_nlink
in struct stat
, instead of trying to guess it
ourself. Reported in issue #1372 by Andreas Schwab.Makefile
. Its most useful commands, make clean
and make distclean
, can now be accomplished in a cross-platform
way using python setup.py clean
and python setup.py clean
-a
, respectively. The remainder of the Makefile
contained
Travis CI commands that have been moved to .travis.yml
.EMBED
and LIBEV_EMBED
, etc, build-time environment
variables. Instead, use GEVENTSETUP_EMBED
and
GEVENTSETUP_EMBED_LIBEV
. See issue #1402.config.guess
to the latest.STARTUPINFO
passed as a parameter.
Contributed by AndCycle in pull request #1352.WIFSTOPPED
and SIGCHLD
are now handled for
determining Popen.returncode
. See
https://bugs.python.org/issue29335pass_fds
. This is a bugfix from Python 3.7 applied to all versions
gevent runs on.TypeError
sooner rather than an
AttributeError
later. This is also slightly faster on CPython with
Cython. Inspired by issue #1363 as reported by Carson Ip. This
means that some extreme corner cases that might have passed by
replacing a Greenlet’s parent with something that’s not a gevent hub
now no longer will.spawning_stack
for Greenlets on CPython should now have
correct line numbers in more cases. See pull request #1379.gevent.ssl.SSLSocket.makefile()
can be used as a
context manager on Python 2._thread_
module from
futures
has already been imported at monkey-patch time, also
patch this module to be consistent. The pkg_resources
package
imports this, and pkg_resources
is often imported early on
Python 2 for namespace packages, so if futures
is installed this
will likely be the case.io.BufferedWriter
is wrapped
around a socket. Reported by Damien Tournoud in issue #1318.examples/process.py
do something useful. See
pull request #1378 by Robert Iannucci.Next page: Changelog