gevent
Read the documentation online at http://www.gevent.org.
Post issues on the bug tracker, discuss and ask open ended questions on the mailing list, and find announcements and information on the blog and twitter (@gevent).
Read the documentation online at http://www.gevent.org.
Post issues on the bug tracker, discuss and ask open ended questions on the mailing list, and find announcements and information on the blog and twitter (@gevent).
Would be cool to have python3 support, ideally as single source.
Here's an old python3 fork: http://bitbucket.org/jjonte/gevent
Denis.Bilenko said, at 2011-01-28T05:36:07.000Z:
There's some work going on at https://bitbucket.org/Edmund_Ogban/gevent-py3k
[email protected] said, at 2011-03-20T18:40:50.000Z:
Exception handling is a problem here. With Python2.5 there is only except Exception, e, whereas Python3.x requires except Exception as e.
Making this single source supporting 2.5 and higher is therefore quite difficult. Or is there some future that can be used to simulate the new syntax included with the language since 2.6?
Otherwise I would say: drop support for Python 2.5 with the next release version, and make that one compatible with 2.6 .. 3.2.
anacrolix said, at 2011-09-13T00:03:14.000Z:
I'm keen to try gevent, but I sailed for Python3 over a year ago.
anacrolix said, at 2011-09-20T00:23:26.000Z:
Denis can you report on the status of Python3 support for gevent?
Denis.Bilenko said, at 2011-12-20T18:14:35.000Z:
Issue 89 has been merged into this issue.
luchenue said, at 2011-12-23T09:14:52.000Z:
Any news ?
anacrolix said, at 2011-12-23T11:09:10.000Z:
From what I've observed, I don't think Denis wants to break support for Python 2 yet, and so won't accept patches that don't support both 2 *and* 3, which is a complex obstacle.
k.cherkasoff said, at 2011-12-23T11:42:53.000Z:
Is there any up to date forks for python 3.x ?
whitelynx said, at 2012-02-01T07:13:18.000Z:
I think the general approach for maintaining anything that's supposed to work on 2.5 - 3.x is to use the 2to3 tool to automatically generate a python3 version from the python2 source. The exception handling issue mentioned by carsten above (comment 2) is treated by the 'except' fixer in 2to3. (http://docs.python.org/library/2to3.html?highlight=except#2to3fixer-except) Since fixers can be run individually, it shouldn't be too difficult to put together a 2to3 command line that would be able to translate gevent with a minimum amount of breakage, and then just manually clean up the results. I do wish there was a 3to2 or similar that would translate some of the python3-style idioms to something compatible with 2.5, as with the 'except _ as _' syntax.
amcnabb8 said, at 2012-02-09T19:14:00.000Z:
The six library makes it very easy to support both Python 2 (>=2.6) and Python 3 without needing 2to3. With a couple of workarounds, Michael Foord has shown that it's entirely possible to support Python 2.4 without 2to3. But really, it's not as hard as it sounds to support both Python 2 and 3, and there are two reasonable approaches.
PyVer: python3As per the discussions on #pypy @ irc.freenode.org, it's been reported that pypycore
runs successfully, with minor as of yet unfixed bugs, on PyPy 2.0 dev and is able to outperform gevent
on CPython in some benchmarks by a factor of 2.
So in general, could we hope for a future direction of the adaptations in pypycore
becoming an integral part of gevent
? Something comparable to how gevent-zeromq
has become part of pyzmq
in recent versions (http://zeromq.github.com/pyzmq/api/zmq.green.html#module-zmq.green).
This would, in the future, give us an awesome stack of gevent and ZeroMQ running on PyPy with the currently under development but functional JIT compilation support for continulet
based stacks (which include greenlet
and stackless
), easily on par in its potential with the success of Node.js.
On Python 3.11a6 and newer, get the PyFrameObject structure from the internal C API ("internal/pycore_frame.h").
On Python 3.9 and newer, use PyFrame_GetBack() and PyFrame_GetCode().
Add frame getter and setter functions to greenlet:
greenlet.h: the CFrame type has been renamed to _PyCFrame.
Greenlets in greenlet
always get their finally
block invoked for example when a KeyboardInterrupt
occurs. To reproduce:
import time, greenlet
def bar():
try: greenlet.getcurrent().parent.switch()
finally: print "CLEANUP BAR"
def foo():
try: time.sleep(1.0)
finally: print "CLEANUP FOO"
b1 = greenlet.greenlet(bar)
b1.switch()
b2 = greenlet.greenlet(bar)
b2.switch()
greenlet.greenlet(foo).switch()
...2 x CLEANUP BAR
+ 1 x CLEANUP FOO
gets printed when Ctrl-C
is pressed during that time.sleep(1.0)
call.
However, when using gevent
(unless time.sleep
is used, for obvious reasons), no cleanup code gets invoked whatsoever when Ctrl-C
is pressed:
from gevent import spawn, sleep
from gevent.event import Event
def bar():
try: Event().wait() # just block and switch back to main
finally: print "CLEANUP BAR"
def foo():
try: sleep(1.0)
finally: print "CLEANUP FOO" # this does get printed for obvious reasons if time.sleep is used instead
gevent.joinall([spawn(bar), spawn(bar), spawn(foo)])
...neither CLEANUP FOO
nor CLEANUP BAR
gets printed.
This is both weird, because greenlet
already handles this automatically, as well as inconsistent with standard Python semantics, which I suppose should always be sticked to. Violating fundamental semantic guarantees of the language will eventually cause confusion and problems, or at least inconvenience, such as having to manually keep track of all spawned greenlets and to kill them in a global finally
cleanup block, or in a signal handler—i.e. stuff that should be expected from gevent
.
(I've run the above code on OS X 10.7 and 64bit Python 2.7)
P.S. Also, an except KeyboardInterrupt
block never gets invoked either.
When using ctypes callbacks the documentation is as follows:
https://docs.python.org/3/library/ctypes.html#callback-functions
Also, note that if the callback function is called in a thread created outside of Python’s control (e.g. by the foreign code that calls the callback), ctypes creates a new dummy Python thread on every invocation. This behavior is correct for most purposes, but it means that values stored with threading.local will not survive across different callbacks, even when those calls are made from the same C thread.
I need to schedule the execution of the code inside the callback. The execution should happen in the Hub with which the callback has been created in the first place. The "dummy thread" however, is an actual physical pseudo-Python thread, even if Gevent monkey-patched the threading module beforehand.
When registering a callback I can capture the hub
from the current gevent thread.
Is there a safe way to inject a Greenlet into a hub i.e. something like gevent.spawn()
whilst passing the Hub to the spawn from a different physical thread the same way as loop.call_soon_threadsafe
works in asyncio? (https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.AbstractEventLoop.call_soon_threadsafe)?
I am trying to run a socket server with ssl support. For this purpose I am usung flask-socketio which uses gevent behind. I think flask-socketio has nothing to do with ssl options, it is just passing to ssl configurations to gevent init.
Socket server with ssl support was possible, but after re-installing all the pip packages, I started to get the following error.
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/gevent/greenlet.py", line 327, in run
result = self._run(*self.args, **self.kwargs)
File "/usr/local/lib/python2.7/dist-packages/gevent/server.py", line 102, in wrap_socket_and_handle
ssl_socket = self.wrap_socket(client_socket, **self.ssl_args)
File "/usr/local/lib/python2.7/dist-packages/gevent/_ssl2.py", line 410, in wrap_socket
ciphers=ciphers)
File "/usr/local/lib/python2.7/dist-packages/gevent/_ssl2.py", line 93, in __init__
self.do_handshake()
File "/usr/local/lib/python2.7/dist-packages/gevent/_ssl2.py", line 310, in do_handshake
return self._sslobj.do_handshake()
SSLError: [Errno 8] _ssl.c:510: EOF occurred in violation of protocol
<Greenlet at 0x7fbc02c4a9b0: <bound method WSGIServer.wrap_socket_and_handle of <WSGIServer at 0x7fbc03b9b110 fileno=9 address=0.0.0.0:5000>>(<socket at 0x7fbc02bf7590 fileno=76 sock=10.122.97, ('41.234.232.59', 40471))> failed with SSLError
is there any solution?
Type: Bug PyVer: python3In v2.7.8-12 of the Debian python suit, which was released 3 days ago, they added a patch, which, according to the changelog, "Allow building and testing without SSLv3 support"
In fact it removes many of the SSLv3-related constants, including ROTOCOL_SSLv3
, which make gevent fail with a message similar to this:
File "<whatever>/h/local/lib/python2.7/site-packages/gevent/ssl.py", line 386, in <module>
def get_server_certificate(addr, ssl_version=PROTOCOL_SSLv3, ca_certs=None):
NameError: name 'PROTOCOL_SSLv3' is not defined
One could argue that it's not nice for a distribution to haphazardly remove constants that are still there in the upstream version, but these things happen, so... maybe gevent could do something about this? (Like, maybe, move to 'PROTOCOL_SSLv23' instead?)
I haven't encountered this directly, but have now had a couple of New Relic Python agent users raise the problem with us.
The problem is that in the Python subprocess module it has:
import select
_has_poll = hasattr(select, 'poll')
Thus _has_poll will only be true if poll() exists in the select module.
Later it has:
if _has_poll:
stdout, stderr = self._communicate_with_poll(input)
else:
stdout, stderr = self._communicate_with_select(input)
and then in _communicate_with_poll() it has:
poller = select.poll()
The problem is that in gevent monkey patching it will remove the poll() function from the select module.
def patch_select(aggressive=True):
"""Replace :func:`select.select` with :func:`gevent.select.select`.
If aggressive is true (the default), also remove other blocking functions the :mod:`select`.
"""
patch_module('select')
if aggressive:
select = __import__('select')
# since these are blocking we're removing them here. This makes some other
# modules (e.g. asyncore) non-blocking, as they use select that we provide
# when none of these are available.
remove_item(select, 'poll')
remove_item(select, 'epoll')
remove_item(select, 'kqueue')
remove_item(select, 'kevent')
The end result is that if the subprocess module had been imported prior to gevent doing any monkey patching, then gevent is breaking the subprocess module as it has cached that the poll() function existed.
You therefore get:
File "/usr/lib/python2.7/subprocess.py", line 799, in communicate return self._communicate(input)
File "/usr/lib/python2.7/subprocess.py", line 1401, in _communicate stdout, stderr = self._communicate_with_poll(input)
File "/usr/lib/python2.7/subprocess.py", line 1431, in _communicate_with_poll poller = select.poll()
AttributeError: 'module' object has no attribute 'poll'
If gevent is going to remove the poll() function, it should perhaps update the subprocess module and set _have_poll to False to avoid the problem.
One could argue gevent shouldn't need to consider that other modules have cached stuff from the select module, but since subprocess is part of the standard library, may be prudent to consider addressing the problem.
Referencing this here since the stack trace originates in gevent.
#6 0x0000000000549867 in _PyTrash_thread_destroy_chain () at Objects/object.c:2276
#7 0x000000000054992b in _PyTrash_end (tstate=0x9f7e18 <_PyRuntime+166328>) at Objects/object.c:2301
#8 0x000000000055c1eb in tupledealloc (op=0x7ff686941c20) at Objects/tupleobject.c:215
#9 0x0000000000549ba2 in _Py_Dealloc (
op=((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((0x0, None), 83), None), 55), None), 13), None), 42), None), 70), None), 7), None), 8), None), 51), None), None), ()), (...)), (...)), None), None), 15), None), 64), None), 94), None), 76), None), None), None), None), None), None), 91), None), 41), None), None), None), None), 31), None), 4), None), None), None), 78), None), 79), None), None), None), None), None), 92), None), 39), None), 23), None), 93), None), 68), None), 47), None), 74), None), 84), None), 72), None), 98), None), 61), None), 90), None), None), 99), 33)) at Objects/object.c:2389
#10 0x00007ff6877dbd1d in Py_DECREF (op=<optimized out>) at /home/arcivanov/.pyenv/versions/3.11.0rc2/include/python3.11/object.h:538
#11 __pyx_f_6gevent_17_gevent_cgreenlet_8Greenlet__Greenlet__free (__pyx_v_self=__pyx_v_self@entry=0x7ff686929310) at src/gevent/greenlet.c:14915
#12 0x00007ff6877f0cbf in __pyx_pf_6gevent_17_gevent_cgreenlet_8Greenlet_42run (__pyx_v_self=0x7ff686929310) at src/gevent/greenlet.c:14741
#13 __pyx_pw_6gevent_17_gevent_cgreenlet_8Greenlet_43run (__pyx_v_self=<gevent._gevent_cgreenlet.Greenlet at remote 0x7ff686929310>, unused=<optimized out>) at src/gevent/greenlet.c:14521
https://github.com/python/cpython/issues/98110
I don't know if this is a gevent issue or not. On AppVeyor (a Windows CI service), I used to be able to install coverage.py and its gevent dependency just fine (ignore 2.6 for the moment): https://ci.appveyor.com/project/nedbat/coveragepy/build/default-280
Then recently (in the last week), the builds started failing for everything, because Cython wasn't available: https://ci.appveyor.com/project/nedbat/coveragepy/build/default-285
It looks like gevent requires Cython at install time, but only declares that in certain circumstances. I don't see how that has changed recently, but something has.
Can you help?
Error Message (Complete build output in build.txt) :
/usr/bin/clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -pipe -Os -I/opt/local/include -I/opt/local/include -DLIBEV_EMBED=1 -DEV_COMMON= -DEV_CLEANUP_ENABLE=0 -DEV_EMBED_ENABLE=0 -DEV_PERIODIC_ENABLE=0 -DEV_USE_REALTIME=1 -DEV_USE_MONOTONIC=1 -DEV_USE_FLOOR=1 -Isrc/gevent/libev -I/opt/local/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9 -I/private/var/folders/84/d3kmlqs95v78tgttk8pknqh80000gp/T/pip-install-ko7s16ut/gevent_4e61ae38b21f4cc085d31587063bc910/deps -I/private/var/folders/84/d3kmlqs95v78tgttk8pknqh80000gp/T/pip-install-ko7s16ut/gevent_4e61ae38b21f4cc085d31587063bc910/src/gevent/libev -I/private/var/folders/84/d3kmlqs95v78tgttk8pknqh80000gp/T/pip-install-ko7s16ut/gevent_4e61ae38b21f4cc085d31587063bc910/deps/libev -Isrc/gevent -Isrc/gevent/libev -Isrc/gevent/resolver -I. -I/Users/yves/.virtualenvs/passages/include -I/opt/local/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/gevent/libev/corecext.c -o build/temp.macosx-10.11-x86_64-3.9/src/gevent/libev/corecext.o -Wno-unreachable-code -Wno-deprecated-declarations -Wno-incompatible-sysroot -Wno-tautological-compare -Wno-implicit-function-declaration -Wno-unused-value -Wno-macro-redefined
In file included from src/gevent/libev/corecext.c:872:
In file included from src/gevent/libev/libev.h:9:
/private/var/folders/84/d3kmlqs95v78tgttk8pknqh80000gp/T/pip-install-ko7s16ut/gevent_4e61ae38b21f4cc085d31587063bc910/deps/libev/ev.c:4105:34: error: use of undeclared identifier 'have_monotonic'
if (ecb_expect_true (have_monotonic))
^
1 error generated.
error: command '/usr/bin/clang' failed with exit code 1
----------------------------------------
ERROR: Failed building wheel for gevent
Failed to build gevent
ERROR: Could not build wheels for gevent which use PEP 517 and cannot be installed directly
[build.txt](https://github.com/gevent/gevent/files/5863150/build.txt)
Thanks !
Platform: POSIX Platform: Unsupported environmentPython 3.9.9 (main, Nov 18 2021, 07:23:37) [Clang 13.0.0 (clang-1300.0.29.3)] on darwin
ProductName: macOS ProductVersion: 12.6 BuildVersion: 21G115
I expected gevent to perform comparably to asyncio on Python 3.9 and that gevent not have a performance regression on Python 3.11.
All details and reproduction notes are here:
https://dev.to/skywind3000/performance-asyncio-vs-gevent-vs-native-epoll-bnl
I replicated these results on the system described at the top of the issue on Python 3.9 (primarily to see if asyncio really is that much faster). I have not replicated the performance regression on Python 3.11 but trust the results on that benchmark page after replicating the situation on Python 3.9.
All details for reproduction are here:
https://dev.to/skywind3000/performance-asyncio-vs-gevent-vs-native-epoll-bnl
Bottom line - has gevent fallen behind asyncio in performance and will it / can it catch up?
Python 2.7.18 grpcio ==1.30.0 grpcio-tools==1.30.0
Fatal Python error: Segmentation fault Thread 0x0000fffe178bf1e0 <grpc_global_tim> (most recent call first): File "py2/lib64/python2.7/site-packages/gevent-1.2.2-py2.7-linux-aarch64.egg/gevent/_threading.py", line 152 in wait File "/py2/lib64/python2.7/site-packages/gevent-1.2.2-py2.7-linux-aarch64.egg/gevent/_threading.py", line 436 in get File "/py2/lib64/python2.7/site-packages/gevent-1.2.2-py2.7-linux-aarch64.egg/gevent/threadpool.py", line 200 in _worker Thread 0x0000fffe1eb95880 <grpc_global_tim> (most recent call first): File "/py2/lib64/python2.7/site-packages/gevent-1.2.2-py2.7-linux-aarch64.egg/gevent/hub.py", line 691 in run
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x0000fffbc8043470 in raise () from /usr/lib64/libpthread.so.0
[Current thread is 1 (LWP 1066998)]
(gdb) bt
#0 0x0000fffbc8043470 in raise () from /usr/lib64/libpthread.so.0
#1
Running django 3.2 using gunicorn 20.1. I keep seeing this traceback in my logs from gevent/_abstract_linkable.py
assert self._notifier is notifier, (self._notifier, notifier)
.
Traceback (most recent call last):
File "src/gevent/_abstract_linkable.py", line 287, in gevent._gevent_c_abstract_linkable.AbstractLinkable._notify_links
File "src/gevent/_abstract_linkable.py", line 333, in gevent._gevent_c_abstract_linkable.AbstractLinkable._notify_links
AssertionError: (None, <callback at 0x7f3af9646600 args=([],)>)
No other logs surrounding these in the given context.
Is this something to be concerned about or anything I can fix?
ddtrace-run gunicorn --workers 5 --worker-class gevent project_name.wsgi:application
Hello, Thanks for making Gevent living up and active development.
Given that the gevent-websocket (https://pypi.org/project/gevent-websocket/) project has been long inactive - presumably dead - and has many bugs, I wonder if - from the software architecture point of view - gevent project has any interest to step up and implement the websocket support within gevent.
Not wanting to make any kind of comparision, but the only reason we have to stay with eventlet is its native websocket support while performance is low. Gevent delivers much better performance using libev + Cython, and under active development + maintenance. It would be great deal to have websocket support within gevent.
Many thanks.
Given this piece of code:
from gevent import monkey, config, Timeout, sleep
config.loop = 'libev-cext' # No timeout with 'libuv'
monkey.patch_all()
def main():
with Timeout(seconds=0.5) as timeout:
for i in range(10):
sleep(0.1)
timeout.cancel()
timeout.start()
print("Safe")
if __name__ == "__main__":
main()
I'd expect it to execute until the end and print Safe
.
However, the timeout triggers and it fails with Timeout
exception:
Traceback (most recent call last):
File "/home/bullno1/Projects/gevent-bug/timeout.py", line 16, in <module>
main()
File "/home/bullno1/Projects/gevent-bug/timeout.py", line 8, in main
sleep(0.1)
File "/home/bullno1/.cache/pypoetry/virtualenvs/gevent-bug-8hnsNxAf-py3.9/lib/python3.9/site-packages/gevent/hub.py", line 166, in sleep
hub.wait(t)
File "src/gevent/_hub_primitives.py", line 46, in gevent._gevent_c_hub_primitives.WaitOperationsGreenlet.wait
File "src/gevent/_hub_primitives.py", line 55, in gevent._gevent_c_hub_primitives.WaitOperationsGreenlet.wait
File "src/gevent/_waiter.py", line 154, in gevent._gevent_c_waiter.Waiter.get
File "src/gevent/_greenlet_primitives.py", line 61, in gevent._gevent_c_greenlet_primitives.SwitchOutGreenletWithLoop.switch
File "src/gevent/_greenlet_primitives.py", line 61, in gevent._gevent_c_greenlet_primitives.SwitchOutGreenletWithLoop.switch
File "src/gevent/_greenlet_primitives.py", line 65, in gevent._gevent_c_greenlet_primitives.SwitchOutGreenletWithLoop.switch
File "src/gevent/_gevent_c_greenlet_primitives.pxd", line 35, in gevent._gevent_c_greenlet_primitives._greenlet_switch
gevent.timeout.Timeout: 0.5 seconds
This seems to be unique to the libev loop as changing the event loop to libuv
will let the code run until completion.
It seems that there is a bug in gevent.select.select
on windows. After a socket read all data from its peer, and run select.select
again against it, it is still returned as readable, but in fact there is no data in buffer, and a following .recv()
will lead to blocking.
test code:
import gevent
import gevent.monkey
gevent.monkey.patch_all()
import gevent.socket
import gevent.select
server = gevent.socket.socket()
server.bind(('127.0.0.1', 12345))
server.listen(5)
def socket_proc(socket):
data = b''
while True:
r, w, x = gevent.select.select([socket, ], [], [socket, ], timeout=0.1)
if r:
data += socket.recv(1024)
else:
if data:
socket.send((u'%s\n' % len(data)).encode('utf-8'))
data = b''
def listen_proc(server):
while True:
socket, _ = server.accept()
gevent.spawn(socket_proc, socket)
print('start..')
listen_proc(server)
One may use any tcp client, such as netcat, to send a short piece of data to the listening port, and will not receive any reply. Debugging shows that when the program calls the select()
for the 2nd time, it still return the socket object in r
, since there is no pending data in it, the next call to socket.recv()
blocks forever.
It seems this is a windows specific bug, as I've test it on linux and works without problem
I've done the following tests (all on widows, all python version are downloaded from python.org, gevent installed by pip)
So I guess this is something related to libuv
Platform: Windowssendall
on a non-blocking socket could spuriously fail
with a timeout.sys.stderr
has been monkey-patched (not recommended),
exceptions that the hub reports aren't lost and can still be caught.
Reported in :issue:825
by Jelle Smet.selectors.SelectSelector
is properly monkey-patched
regardless of the order of imports. Reported in :issue:835
by
Przemysław Węgrzyn.reload(site)
no longer fails with a TypeError
if
gevent has been imported. Reported in :issue:805
by Jake Hilton.wait
to return prematurely. Reported in :issue:771
by Sergey
Vasilyev.777
by wiggin15.ref
parameter to :func:gevent.os.fork_and_watch
was being ignored.gevent.queue.Channel
is now correctly iterable, instead of
raising a :exc:TypeError
.socket.socket.sendmsg
,
:meth:socket.socket.recvmsg
and :meth:socket.socket.recvmsg_into
on platforms where they are defined. Initial :pr:773
by Jakub
Klama.threading.RLock
now properly
blocks (or deadlocks) in acquire
if the default value for
timeout of -1 is used (which differs from gevent's default of
None). The acquire
method also raises the same :exc:ValueError
exceptions that the standard library does for invalid parameters.
Reported in #750 by Joy Zheng.~gevent.event.Event
that made it
return False
when the event was set and cleared by the same
greenlet before allowing a switch to already waiting greenlets. (Found
by the 3.4 and 3.5 standard library test suites; the same as Python
bug 13502
_. Note that the Python 2 standard library still has this
race condition.)~gevent.event.Event
and :class:~.AsyncResult
now wake
waiting greenlets in the same (unspecified) order. Previously,
AsyncResult
tended to use a FIFO order, but this was never
guaranteed. Both classes also use less per-instance memory.~logging.Logger
as a :mod:pywsgi
error or request
log stream no longer produces extra newlines. Reported in
#756 by ael-code.~gevent.monkey.patch_all
is called with
os
set to False (not the default) but signal
is still True
(the default). This combination of parameters will cause signal
handlers for SIGCHLD
to not get called. In the future this might
raise an error. Reported by Josh Zuech.~gevent.monkey.patch_all
is called more
than once with different arguments. That causes the cumulative set of all True
arguments to be patched, which may cause unexpected results.threading
attributes from :func:gevent.monkey.get_original
.~socket.socket.sendall
method of a gevent SSL socket that has
a timeout now returns immediately (like the standard library does),
instead of incorrectly raising :exc:ssl.SSLEOFError
. (Note that
sending empty data with the :meth:~socket.socket.send
method does raise SSLEOFError
in
both gevent and the standard library.) Reported in #719 by
Mustafa Atik and Tymur Maryokhin, with a reproducible test case
provided by Timo Savola.OverflowError
when using the readline
method of the WSGI input stream without a size hint or with a large size hint when the client is uploading a large amount of data. (This only impacted CPython 2; PyPy and Python 3 already handled this.) Reported in issue #289 by ggjjlldd, with contributions by Nathan Hoad.SSLSocket
now raises the same ValueError the standard library does, instead of an AttributeError
. Found by updating gevent’s copy of the standard library test cases. Initially reported in issue #735 by Dmitrij D. Czarkoff.socket.sendfile
.socket.get/set_inheritable
.gevent.lock.Semaphore
subclasses. If monkey-patched, this could
also apply to :class:threading.Semaphore
objects. Reported in
:issue:660
by Jay Oster.details
_). Thanks to Jay Oster.~.WSGIHandler
to handle invalid HTTP client
requests. Reported by not-bob.~.WSGIServer
more robustly supports :class:~logging.Logger
-like parameters for
log
and error_log
(as introduced in 1.1b1, this could cause
integration issues with gunicorn). Reported in :issue:663
by Jay
Oster.~gevent.threading._DummyThread
objects, created in a
monkey-patched system when :func:threading.current_thread
is
called in a new greenlet (which often happens implicitly, such as
when logging) are much lighter weight. For example, they no longer
allocate and then delete a :class:~gevent.lock.Semaphore
, which is
especially important for PyPy.gevent.pywsgi
formats the status code
correctly on Python 3. Reported in :issue:664
by Kevin Chen.gevent.lock.Semaphore
, which was unintentionally removed
as part of making Semaphore
atomic on PyPy on 1.1b1. Reported in
:issue:666
by Ivan-Zhu.665
by Hexchain Tong.-O
or PYTHONOPTIMIZE
. Previously these would go
undetected if optimizations were enabled, potentially leading to
erratic, difficult to debug behaviour.AttributeError
from gevent.queue.Queue
when peek
was called on an empty Queue
. Reported in #643 by michaelvol.SIGCHLD
handlers specified to signal.signal
work with
the child watchers that are used by default. Also make
os.waitpid
work with a first argument of -1. Noted by users of gunicorn.socket.makefile
. Reported in #644
by Karan Lyons.AttributeError
from gevent.monkey.patch_builtins
on
Python 2 when the future
_ library is also installed. Reported by
Carlos Sanchez.DistutilsModuleError
or ImportError
if the CFFI
module backing gevent.core
needs 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:sendall
with 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.TypeError
when calling gevent.socket.wait
.
Reported in #635 by lanstin.gevent.socket.socket:sendto
properly respects the socket's
blocking status (meaning it can raise EWOULDBLOCK now in cases it
wouldn't have before). Reported in :pr:634
by Mike Kaplinskiy.threaded resolver <gevent.resolver_thread>
are no longer always printed to stderr
since they are usually out of the programmer's control and caught
explicitly. (Programming errors like TypeError
are still
printed.) Reported in :issue:617
by Jay Oster and Carlos Sanchez.TypeError
from gevent.idle()
. Reported in
:issue:639
by chilun2008.imap_unordered
methods of a pool support a maxsize
parameter to limit the number of results buffered waiting for the
consumer. Reported in :issue:638
by Sylvain Zimmer.gevent.queue.Queue
now consistently orders multiple
blocked waiting put
and get
callers 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.Queue
now supports the len()
function.gevent.monkey.patch_builtins
could cause PyPy
to crash. Reported in #618 by Jay Oster.gevent.kill
raises the correct exception in the target greenlet.
Reported in #623 by Jonathan Kamens.readable
and writable
methods to FileObjectPosix
;
this fixes e.g., help() on Python 3 when monkey-patched.setup.py
can be run from a directory containing spaces. Reported
in :issue:319
by Ivan Smirnov.setup.py
can build with newer versions of clang on OS X. They
enforce the distinction between CFLAGS and CPPFLAGS.gevent.lock.Semaphore
is atomic on PyPy, just like it is on
CPython. This comes at a small performance cost.successful
value to
False when killing a greenlet before it ran with a non-default
exception. Fixed in :pr:608
by Heungsub Lee.os.waitpid
to become unreliable
due to the use of signals on POSIX platforms. This was especially
noticeable when using gevent.subprocess
in combination with
multiprocessing
. Now, the monkey-patched os
module provides
a waitpid
function that seeks to ameliorate this. Reported in
:issue:600
by champax and :issue:452
by Łukasz Kawczyński.select.poll
, provide a
gevent-friendly gevent.select.poll
and corresponding
monkey-patch. Implemented in :pr:604
by Eddi Linder.531
by M. Nunberg and implemented in :pr:604
.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.error
on Python 2,
RuntimeError
on Python 3). Previously, over-releasing a lock was
silently ignored. Reported in :issue:308
by Jędrzej Nowak.gevent.fileobject.FileObjectThread
uses the threadpool to close
the underling file-like object. Reported in :issue:201
by
vitaly-krugl.gevent.pywsgi
handler 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.threading
module before using
gevent.monkey.patch_all()
no longer causes Python 3.4 to fail to
get the repr
of the main thread, and other CPython platforms to
return an unjoinable DummyThread. (Note that this is not
recommended.) Reported in :issue:153
.io
package to implement
FileObjectPosix
. This unifies the code with the Python 3
implementation, and fixes problems with using seek()
. See
:issue:151
.108
by shaun and initial fix based on code by
Sylvain Zimmer.gevent.spawn
, spawn_raw
and spawn_later
, as well as the
Greenlet
constructor, immediately produce useful TypeError
s
if asked to run something that cannot be run. Previously, the
spawned greenlet would die with an uncaught TypeError
the first
time it was switched to. Reported in :issue:119
by stephan.gevent.threadpool.ThreadPool.apply
no longer
raises a LoopExit
error (using ThreadPool.spawn
and then
get
on the result still could; you must be careful to use the
correct hub). Reported in :issue:131
by 8mayday.threading
module is monkey-patched, the module-level
lock in the logging
module 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 Logger
instance before monkey-patching. Configuring
logging
with a basic configuration and then monkey-patching is
also safer (but not configurations that involve such things as the
SocketHandler
).threading.RLock
under Python 3.RuntimeError
from importlib
. Reported in :issue:615
by Daniel Mizyrycki.
(The same thing could happen under Python 2 if a threading.RLock
was held around the monkey-patching call; this is less likely but
not impossible with import hooks.)381
and fixed in :pr:616
by Chris
Lane.pywsgi.WSGIServer
accept a
logging.Logger
instance for its log
and (new) error_log
parameters. 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
.gevent.threadpool.ThreadPool.imap
and imap_unordered
now
accept multiple iterables.ThreadPool
or Group
mapping/application functions should now
have the original traceback.gevent.threadpool.ThreadPool.apply
now raises any exception
raised by the called function, the same as
gevent.pool.Group
/Pool
and the builtin apply
function.
This obsoletes the undocumented apply_e
function. Original PR
#556 by Robert Estelle.selectors
module from patch_all
and
patch_select
on Python 3.4. See #591 .gevent.monkey
module
allow knowing what was patched. Discussed in :issue:135
and
implemented in :pr:325
by Nathan Hoad.597
by David Ford.gevent.socket.socket.sendall
supports arbitrary objects that
implement the buffer protocol (such as ctypes structures), just like
native sockets. Reported in :issue:466
by tzickel.onerror
attribute 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.subprocess
module is closer in behaviour to the
standard library under Python 3, at least on POSIX. The
pass_fds
, restore_signals
, and start_new_session
arguments are now unimplemented, as are the timeout
parameters
to various functions. Under Python 2, the previously undocumented timeout
parameter to Popen.communicate
raises an exception like its
Python 3 counterpart.gevent.subprocess
module no longer leaks file descriptors. Reported in :pr:374
by 陈小玉.echoserver.py
no longer binds to the standard X11
TCP port. Reported in :issue:485
by minusf.gevent.iwait
no longer throws LoopExit
if the caller
switches greenlets between return values. Reported and initial patch
in :pr:467
by Alexey Borzenkov.multiprocessing.Process
.
Previously the child process would hang indefinitely. Reported in
:issue:230
by Lx Yu.gevent.killall
accepts an arbitrary iterable for the greenlets
to kill. Reported in :issue:404
by Martin Bachwerk; seen in
combination with older versions of simple-requests.gevent.local.local
objects 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.kill
or
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.See the changelog for a detailed list of changes.
Source code(tar.gz)See https://github.com/gevent/gevent/blob/1.0.2/changelog.rst#release-102-may-23-2015 for a list of changes.
Source code(tar.gz)See https://github.com/surfly/gevent/blob/1.0.x/changelog.rst#release-101-apr-30-2014 for list of changes
Source code(tar.gz)Final version of gevent 1.0.
Source code(tar.gz)Responses A utility library for mocking out the requests Python library. Note Responses requires Python 2.7 or newer, and requests >= 2.0 Installing p
httmock A mocking library for requests for Python 2.7 and 3.4+. Installation pip install httmock Or, if you are a Gentoo user: emerge dev-python/httm
Welcome to nose2 nose2 is the successor to nose. It's unittest with plugins. nose2 is a new project and does not support all of the features of nose.
What's this This is a high performance python wsgi web server. And Meinheld is a WSGI compliant web server. (PEP333 and PEP3333 supported) You can als
Green -- A clean, colorful, fast python test runner. Features Clean - Low redundancy in output. Result statistics for each test is vertically aligned.
Locust Locust is an easy to use, scriptable and scalable performance testing tool. You define the behaviour of your users in regular Python code, inst
PyAutoGUI PyAutoGUI is a cross-platform GUI automation Python module for human beings. Used to programmatically control the mouse & keyboard. pip inst
splinter - python tool for testing web applications splinter is an open source tool for testing web applications using Python. It lets you automate br
FreezeGun: Let your Python tests travel through time FreezeGun is a library that allows your Python tests to travel through time by mocking the dateti
HTTPretty 1.0.5 HTTP Client mocking tool for Python created by Gabriel Falcão . It provides a full fake TCP socket module. Inspired by FakeWeb Github
factory_boy factory_boy is a fixtures replacement based on thoughtbot's factory_bot. As a fixtures replacement tool, it aims to replace static, hard t
The Mixer is a helper to generate instances of Django or SQLAlchemy models. It's useful for testing and fixture replacement. Fast and convenient test-
Faker is a Python package that generates fake data for you. Whether you need to bootstrap your database, create good-looking XML documents, fill-in yo
Mimesis - Fake Data Generator Description Mimesis is a high-performance fake data generator for Python, which provides data for a variety of purposes
WhiteNoise Radically simplified static file serving for Python web apps With a couple of lines of config WhiteNoise allows your web app to serve its o
LiveReload Reload webpages on changes, without hitting refresh in your browser. Installation python-livereload is for web developers who know Python,
bjoern: Fast And Ultra-Lightweight HTTP/1.1 WSGI Server A screamingly fast, ultra-lightweight WSGI server for CPython 2 and CPython 3, written in C us
Waitress Waitress is a production-quality pure-Python WSGI server with very acceptable performance. It has no dependencies except ones which live in t
Python HTTP Server Preview Languange and Code Editor: How to run? Download the zip first. Open the http.py and wait 1-2 seconds. You will see __pycach