Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gevent
Commits
4780e09c
Commit
4780e09c
authored
Feb 24, 2016
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update changelog with more links; add more/update/fix ..versionXXX in docstrings.
parent
39eb5eaf
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
201 additions
and
96 deletions
+201
-96
changelog.rst
changelog.rst
+93
-82
doc/gevent.threadpool.rst
doc/gevent.threadpool.rst
+5
-1
doc/mytheme/static/basic.css_t
doc/mytheme/static/basic.css_t
+4
-0
doc/whatsnew_1_1.rst
doc/whatsnew_1_1.rst
+1
-0
gevent/_fileobjectposix.py
gevent/_fileobjectposix.py
+6
-0
gevent/fileobject.py
gevent/fileobject.py
+5
-0
gevent/greenlet.py
gevent/greenlet.py
+12
-4
gevent/hub.py
gevent/hub.py
+10
-0
gevent/local.py
gevent/local.py
+9
-0
gevent/lock.py
gevent/lock.py
+5
-1
gevent/monkey.py
gevent/monkey.py
+3
-0
gevent/os.py
gevent/os.py
+2
-2
gevent/pool.py
gevent/pool.py
+2
-0
gevent/pywsgi.py
gevent/pywsgi.py
+6
-1
gevent/queue.py
gevent/queue.py
+17
-3
gevent/signal.py
gevent/signal.py
+4
-0
gevent/subprocess.py
gevent/subprocess.py
+17
-2
No files found.
changelog.rst
View file @
4780e09c
...
...
@@ -49,10 +49,12 @@
Also raise the correct exceptions for unconnected SSL sockets and
properly validate SSL hostnames. Found via updated standard library
tests.
- Python 3: Add missing support for
``socket.socket.sendfile`
`. Found via updated
- Python 3: Add missing support for
:meth:`socket.socket.sendfile
`. Found via updated
standard library tests.
- Python 3.4+: Add missing support for ``socket.get/set_inheritable``. Found
via updated standard library tests.
- Python 3.4+: Add missing support for
:meth:`socket.socket.get_inheritable` and
:meth:`~socket.socket.set_inheritable`. Found via updated standard
library tests.
1.1rc3 (Jan 04, 2016)
=====================
...
...
@@ -89,7 +91,7 @@
``sendall``.
- gevent's SSL socket's ``sendall`` method should no longer raise ``SSL3_WRITE_PENDING``
in rare cases when sending large buffers. Reported in :issue:`317`.
-
``gevent.signal`
` now allows resetting (SIG_DFL) and ignoring (SIG_IGN) the
-
:func:`gevent.signal.signal
` now allows resetting (SIG_DFL) and ignoring (SIG_IGN) the
SIGCHLD signal at the process level (although this may allow race
conditions with libev child watchers). Reported in :issue:`696` by
Adam Ning.
...
...
@@ -180,16 +182,16 @@
1.1b5 (Sep 18, 2015)
====================
-
``gevent.subprocess`
` works under Python 3.5. In general, Python 3.5
-
:mod:`gevent.subprocess
` works under Python 3.5. In general, Python 3.5
has preliminary support. Reported in :issue:`653` by Squeaky.
-
``gevent.subprocess.Popen.communicate`
` honors a ``timeout``
-
:func:`Popen.communicate <gevent.subprocess.Popen.communicate>
` honors a ``timeout``
argument even if there is no way to communicate with the child
process (none of stdin, stdout and stderr were set to ``PIPE``).
Noticed as part of the Python 3.5 test suite for the new function
``subprocess.run`` but impacts all versions (``timeout`` is an
official argument under Python 3 and a gevent extension with
slightly different semantics under Python 2).
- Fix a possible ``ValueError`` from
``gevent.queue.Queue:peek`
`.
- Fix a possible ``ValueError`` from
:meth:`Queue.peek <gevent.queue.Queue.peek>
`.
Reported in :issue:`647` by Kevin Chen.
- Restore backwards compatibility for using ``gevent.signal`` as a
callable, which, depending on the order of imports, could be broken
...
...
@@ -197,7 +199,7 @@
:issue:`648` by Sylvain Zimmer.
- gevent blocking operations performed at the top-level of a module
after the system was monkey-patched under Python 2 could result in
raising a
``LoopExit`
` instead of completing the expected blocking
raising a
:exc:`~gevent.hub.LoopExit
` instead of completing the expected blocking
operation. Note that performing gevent blocking operations in the
top-level of a module is typically not recommended, but this
situation can arise when monkey-patching existing scripts. Reported
...
...
@@ -206,20 +208,21 @@
(monkey-patched) ``os.forkpty`` and ``pty.fork`` functions in the
same way they do for the ``os.fork`` function. Reported in
:issue:`650` by Erich Heine.
- ``gevent.pywsgi.WSGIServer`` (``WSGIHandler``) does a better job detecting and
- :class:`~gevent.pywsgi.WSGIServer` and
:class:`~gevent.pywsgi.WSGIHandler` do a better job detecting and
reporting potential encoding errors for headers and the status line
during
``start_response`` as recommended by the `WSGI specification`_.
In addition, under Python 2, unnecessary encodings and de
codings
(often a trip through the ASCII encoding) are avoided for conforming
applications. This is an enhancement of an already documented and
partially enforced constraint: beginning in 1.1a1, under Python 2
,
``u'abc'`` would typically previously have been allowed, but
``u'\u1f4a3'`` would not; now, neither will be allowed, more closely
m
atching the specification, improving debugability and performance
and allowing for better error handling both by the application and
by gevent (previously, certain encoding errors could result in
gevent writing invalid/malformed HTTP responses). Reported by Greg
Higgins and Carlos Sanchez.
during
:meth:`~gevent.pywsgi.WSGIHandler.start_response` as recommended by the `WSGI
specification`_. In addition, under Python 2, unnecessary en
codings
and decodings (often a trip through the ASCII encoding) are avoided
for conforming applications. This is an enhancement of an already
documented and partially enforced constraint: beginning in 1.1a1
,
under Python 2, ``u'abc'`` would typically previously have been
allowed, but ``u'\u1f4a3'`` would not; now, neither will be allowed,
m
ore closely matching the specification, improving debugability and
performance and allowing for better error handling both by the
application and by gevent (previously, certain encoding errors could
result in gevent writing invalid/malformed HTTP responses). Reported
by Greg
Higgins and Carlos Sanchez.
- Code coverage by tests is now reported on `coveralls.io`_.
.. _WSGI specification: https://www.python.org/dev/peps/pep-3333/#the-start-response-callable
...
...
@@ -235,9 +238,11 @@
erratic, difficult to debug behaviour.
- Fix an ``AttributeError`` from ``gevent.queue.Queue`` when ``peek``
was called on an empty ``Queue``. Reported in :issue:`643` by michaelvol.
- Make ``SIGCHLD`` handlers specified to
``signal.signal`
` work with
- Make ``SIGCHLD`` handlers specified to
:func:`gevent.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.
:func:`gevent.os.waitpid` work with a first argument of -1. (Also
applies to the corresponding monkey-patched stdlib functions.)
Noted by users of gunicorn.
- Under Python 2, any timeout set on a socket would be ignored when
using the results of ``socket.makefile``. Reported in :issue:`644`
by Karan Lyons.
...
...
@@ -271,15 +276,16 @@
printed.) Reported in :issue:`617` by Jay Oster and Carlos Sanchez.
- PyPy: Fix a ``TypeError`` from ``gevent.idle()``. Reported in
:issue:`639` by chilun2008.
- The ``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.
- The class ``gevent.queue.Queue`` now consistently orders multiple
- The :func:`~gevent.pool.Pool.imap_unordered` methods of a pool-like
object support a ``maxsize`` parameter to limit the number of
results buffered waiting for the consumer. Reported in :issue:`638`
by Sylvain Zimmer.
- The class :class:`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.
- The class
``gevent.queue.Queue`` now supports the ``len()`
` function.
- The class
:class:`gevent.queue.Queue` now supports the :func:`len
` function.
.. _future: http://python-future.org
.. _bench_sendall.py: https://raw.githubusercontent.com/gevent/gevent/master/greentest/bench_sendall.py
...
...
@@ -294,12 +300,14 @@
- On some versions of PyPy on some platforms (notably 2.6.0 on 64-bit
Linux), enabling ``gevent.monkey.patch_builtins`` could cause PyPy
to crash. Reported in :issue:`618` by Jay Oster.
-
``gevent.kill`
` raises the correct exception in the target greenlet.
-
:func:`gevent.kill
` raises the correct exception in the target greenlet.
Reported in :issue:`623` by Jonathan Kamens.
- Various fixes on Windows. Reported in :issue:`625`, :issue:`627`,
and :issue:`628` by jacekt and Yuanteng (Jeff) Pei. Fixed in :pr:`624`.
- Add ``readable`` and ``writable`` methods to ``FileObjectPosix``;
this fixes e.g., help() on Python 3 when monkey-patched.
- Add :meth:`~gevent.fileobject.FileObjectPosix.readable` and
:meth:`~gevent.fileobject.FileObjectPosix.writable` methods to
:class:`~gevent.fileobject.FileObjectPosix`; this fixes e.g., help() on Python 3 when
monkey-patched.
1.1b1 (Jul 17, 2015)
====================
...
...
@@ -313,28 +321,28 @@
- Fixed regression that failed to set the ``successful`` value to
False when killing a greenlet before it ran with a non-default
exception. Fixed in :pr:`608` by Heungsub Lee.
- libev's child watchers caused
``os.waitpid`
` to become unreliable
- libev's child watchers caused
:func:`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
noticeable when using
:mod:`gevent.subprocess
` in combination with
``multiprocessing``. Now, the monkey-patched ``os`` module provides
a
``waitpid`
` function that seeks to ameliorate this. Reported in
a
:func:`~gevent.os.waitpid
` function that seeks to ameliorate this. Reported in
:issue:`600` by champax and :issue:`452` by Łukasz Kawczyński.
- On platforms that implement
``select.poll`
`, provide a
gevent-friendly
``gevent.select.poll`
` and corresponding
- On platforms that implement
:class:`select.poll
`, provide a
gevent-friendly
:class:`gevent.select.poll
` and corresponding
monkey-patch. Implemented in :pr:`604` by Eddi Linder.
- Allow passing of events to the io callback under PyPy. Reported in
:issue:`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
-
:func:`gevent.thread.allocate_lock
` (and so a monkey-patched standard
library
:func:`~thread.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
-
:class:`gevent.fileobject.FileObjectThread
` uses the threadpool to close
the underling file-like object. Reported in :issue:`201` by
vitaly-krugl.
- Malicious or malformed HTTP chunked transfer encoding data sent to
the
``gevent.pywsgi`` handler
is handled more robustly, resulting in
the
:class:`pywsgi handler <gevent.pywsgi.WSGIHandler>`
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.
...
...
@@ -344,7 +352,7 @@
return an unjoinable DummyThread. (Note that this is not
recommended.) Reported in :issue:`153`.
- Under Python 2, use the ``io`` package to implement
``FileObjectPosix`
`. This unifies the code with the Python 3
:class:`~gevent.fileobject.FileObjectPosix
`. This unifies the code with the Python 3
implementation, and fixes problems with using ``seek()``. See
:issue:`151`.
- Under Python 2, importing a module that uses gevent blocking
...
...
@@ -352,35 +360,37 @@
produces import errors (Python 3 handles this case natively).
Reported in :issue:`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 ``TypeErrors``
-
:func:`gevent.spawn`, :func:`spawn_raw` and :func:`spawn_later
`, as well as the
:class:`~gevent.Greenlet
` constructor, immediately produce useful ``TypeErrors``
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.
- Recursive use of ``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.
- When the ``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``).
- Fix monkey-patching of ``threading.RLock`` under Python 3.
- Recursive use of :meth:`ThreadPool.apply
<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.
- When the :mod:`threading` module is :func:`monkey-patched
<gevent.monkey.patch_thread>`, the module-level lock in the
:mod:`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
:class:`~logging.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``).
- Fix monkey-patching of :class:`threading.RLock` under Python 3.
- Under Python 3, monkey-patching at the top-level of a module that
was imported by another module could result in a
``RuntimeError`
`
from
``importlib`
`. Reported in :issue:`615` by Daniel Mizyrycki.
was imported by another module could result in a
:exc:`RuntimeError
`
from
:mod:`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.)
- Fix configuring c-ares for a 32-bit Python when running on a 64-bit
platform. Reported in :issue:`381` and fixed in :pr:`616` by Chris
Lane. Additional fix in :pr:`626` by Kevin Chen.
- (Experimental) Let the
``pywsgi.WSGIServer`
` accept a
``logging.Logger`
` instance for its ``log`` and (new) ``error_log``
- (Experimental) Let the
:class:`pywsgi.WSGIServer
` accept a
:class:`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`.
...
...
@@ -393,11 +403,11 @@
- (Experimental) Exceptions raised from iterating using the
``ThreadPool`` or ``Group`` mapping/application functions should now
have the original traceback.
-
``gevent.threadpool.ThreadPool.apply`
` now raises any exception
-
:meth:`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
:issue:`556` by Robert Estelle.
:class:`~gevent.pool.Group`/:class:`~gevent.pool.Pool` and the
builtin :func:`apply` function. This obsoletes the undocumented
``apply_e`` function. Original PR
:issue:`556` by Robert Estelle.
- Monkey-patch the ``selectors`` module from ``patch_all`` and
``patch_select`` on Python 3.4. See :issue:`591`.
- Additional query functions for the :mod:`gevent.monkey` module
...
...
@@ -406,41 +416,42 @@
- In non-monkey-patched environments under Python 2.7.9 or above or
Python 3, using a gevent SSL socket could cause the greenlet to
block. See :issue:`597` by David Ford.
-
``gevent.socket.socket.sendall`
` supports arbitrary objects that
-
:meth:`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.
- Added support for the ``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)
- The
``gevent.subprocess`
` module is closer in behaviour to the
- The
:mod:`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
arguments are now implemented, as are the ``timeout`` parameters
to various functions. Under Python 2, the previously undocumented
``timeout`` parameter to :meth:`Popen.communicate
<gevent.subprocess.Popen.communicate>` raises an exception like its
Python 3 counterpart.
- An exception starting a child process with the
``gevent.subprocess`
`
- An exception starting a child process with the
:mod:`gevent.subprocess
`
module no longer leaks file descriptors. Reported in :pr:`374` by 陈小玉.
- The example ``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
-
:func:`gevent.iwait` no longer throws :exc:`~gevent.hub.LoopExit
` if the caller
switches greenlets between return values. Reported and initial patch
in :
pr
:`467` by Alexey Borzenkov.
in :
issue
:`467` by Alexey Borzenkov.
- The default threadpool and default threaded resolver work in a
forked child process, such as with
``multiprocessing.Process`
`.
forked child process, such as with
:class:`multiprocessing.Process
`.
Previously the child process would hang indefinitely. Reported in
:issue:`230` by Lx Yu.
- Fork watchers are more likely to (eventually) get called in a
multi-threaded program (except on Windows). See :issue:`154`.
-
``gevent.killall`
` accepts an arbitrary iterable for the greenlets
-
:func:`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
-
:class:`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
behaviour of the built-in
:class:`threading.local
` (when implemented
natively). Reported in :issue:`387` by AusIV.
- Killing a greenlet (with
``gevent.kill`
` or
``gevent.greenlet.Greenlet.kill`
`) before it is actually started and
- Killing a greenlet (with
:func:`gevent.kill
` or
:meth:`gevent.Greenlet.kill
`) before it is actually started and
switched to now prevents the greenlet from ever running, instead of
raising an exception when it is later switched to. See :issue:`330`
reported by Jonathan Kamens.
...
...
@@ -455,9 +466,9 @@
you'll need a very recent PyPy build including CFFI 1.2.0.
- Drop support for Python 2.5. Python 2.5 users can continue to use
gevent 1.0.x.
- Fix
``gevent.greenlet.joinall`
` to not ignore ``count`` when
- Fix
:func:`gevent.joinall
` to not ignore ``count`` when
``raise_error`` is False. See :pr:`512` by Ivan Diao.
- Fix
``subprocess.Popen`
` to not ignore the ``bufsize`` argument. Note
- Fix
:class:`gevent.subprocess.Popen
` to not ignore the ``bufsize`` argument. Note
that this changes the (platform dependent) default, typically from
buffered to unbuffered. See :pr:`542` by Romuald Brunet.
- Upgraded c-ares to 1.10.0. See :pr:`579` by Omer Katz.
...
...
@@ -467,9 +478,9 @@
and they may have to be modified (for example, ``CFLAGS`` is no
longer allowed to include ``-I`` directives, which must instead be
placed in ``CPPFLAGS``).
- Add a ``count`` argument to
``gevent.greenlet.wait`
`. See :pr:`482` by
- Add a ``count`` argument to
:func:`gevent.iwait
`. See :pr:`482` by
wiggin15.
- Add a ``timeout`` argument to
``gevent.queue.JoinableQueue.wait`
`
- Add a ``timeout`` argument to
:meth:`gevent.queue.JoinableQueue.join
`
which now returns whether all items were waited for or not.
- ``gevent.queue.JoinableQueue`` treats ``items`` passed to
``__init__`` as unfinished tasks, the same as if they were ``put``.
...
...
doc/gevent.threadpool.rst
View file @
4780e09c
...
...
@@ -25,4 +25,8 @@
.. note:: As implemented, attempting to use
:meth:`Threadpool.appy` from inside another function that
was itself spawned in a threadpool (any threadpool) will
cause the function to be run immediatesly.
cause the function to be run immediately.
.. versionchanged:: 1.1a2
Now raises any exception raised by *func* instead of
dropping it.
doc/mytheme/static/basic.css_t
View file @
4780e09c
...
...
@@ -979,6 +979,10 @@ dl.glossary dt {
margin: 0;
}
th.field-name {
vertical-align: top;
}
.refcount {
color: #060;
}
...
...
doc/whatsnew_1_1.rst
View file @
4780e09c
...
...
@@ -163,6 +163,7 @@ include:
- Almost anywhere that gevent raises an exception from one greenlet to
another (e.g., :meth:`Greenlet.get <gevent.Greenlet.get>`),
the original traceback is preserved and raised.
- Various logging/debugging outputs have been cleaned up.
- The WSGI server found in :mod:`gevent.pywsgi` is more robust against
errors in either the client or the WSGI application, fixing several
hangs or HTTP protocol violations. It also supports new
...
...
gevent/_fileobjectposix.py
View file @
4780e09c
...
...
@@ -275,9 +275,15 @@ class FileObjectPosix(object):
return
self
.
io
.
readlines
(
sizehint
)
def
readable
(
self
):
"""
.. versionadded:: 1.1b2
"""
return
self
.
io
.
readable
()
def
writable
(
self
):
"""
.. versionadded:: 1.1b2
"""
return
self
.
io
.
writable
()
def
seek
(
self
,
*
args
,
**
kwargs
):
...
...
gevent/fileobject.py
View file @
4780e09c
...
...
@@ -110,6 +110,11 @@ class FileObjectThread(object):
return
self
.
threadpool
.
apply
(
func
,
args
,
kwargs
)
def
close
(
self
):
"""
.. versionchanged:: 1.1b1
The file object is closed using the threadpool. Note that whether or
not this action is synchronous or asynchronous is not documented.
"""
fobj
=
self
.
io
if
fobj
is
None
:
return
...
...
gevent/greenlet.py
View file @
4780e09c
...
...
@@ -127,7 +127,7 @@ class Greenlet(greenlet):
:keyword run: The callable object to run. If not given, this object's
`_run` method will be invoked (typically defined by subclasses).
.. versionchanged:: 1.1
a3
.. versionchanged:: 1.1
b1
The ``run`` argument to the constructor is now verified to be a callable
object. Previously, passing a non-callable object would fail after the greenlet
was spawned.
...
...
@@ -357,6 +357,10 @@ class Greenlet(greenlet):
This can be used as ``gevent.spawn`` or ``Greenlet.spawn``.
The arguments are passed to :meth:`Greenlet.__init__`.
.. versionchanged:: 1.1b1
If a *function* is given that is not callable, immediately raise a :exc:`TypeError`
instead of spawning a greenlet that will raise an uncaught TypeError.
"""
g
=
cls
(
*
args
,
**
kwargs
)
g
.
start
()
...
...
@@ -371,7 +375,7 @@ class Greenlet(greenlet):
The arguments are passed to :meth:`Greenlet.__init__`.
.. versionchanged:: 1.1
a3
.. versionchanged:: 1.1
b1
If an argument that's meant to be a function (the first argument in *args*, or the ``run`` keyword )
is given to this classmethod (and not a classmethod of a subclass),
it is verified to be callable. Previously, the spawned greenlet would have failed
...
...
@@ -655,7 +659,7 @@ def killall(greenlets, exception=GreenletExit, block=True, timeout=None):
"""
Forceably terminate all the ``greenlets`` by causing them to raise ``exception``.
:param greenlets: A
bounded
iterable of the non-None greenlets to terminate.
:param greenlets: A
**bounded**
iterable of the non-None greenlets to terminate.
*All* the items in this iterable must be greenlets that belong to the same thread.
:keyword exception: The exception to raise in the greenlets. By default this is
:class:`GreenletExit`.
...
...
@@ -667,8 +671,12 @@ def killall(greenlets, exception=GreenletExit, block=True, timeout=None):
the exception asynchronously.
:keyword float timeout: A time in seconds to wait for greenlets to die. If given, it is
only honored when ``block`` is True.
:raise
s
Timeout: If blocking and a timeout is given that elapses before
:raise Timeout: If blocking and a timeout is given that elapses before
all the greenlets are dead.
.. versionchanged:: 1.1a2
*greenlets* can be any iterable of greenlets, like an iterator or a set.
Previously it had to be a list or tuple.
"""
# support non-indexable containers like iterators or set objects
greenlets
=
list
(
greenlets
)
...
...
gevent/hub.py
View file @
4780e09c
...
...
@@ -134,6 +134,10 @@ def spawn_raw(function, *args, **kwargs):
occasionally be useful as an optimization if there are many
greenlets involved.
.. versionchanged:: 1.1b1
If *function* is not callable, immediately raise a :exc:`TypeError`
instead of spawning a greenlet that will raise an uncaught TypeError.
.. versionchanged:: 1.1rc2
Accept keyword arguments for ``function`` as previously (incorrectly)
documented. Note that this may incur an additional expense.
...
...
@@ -929,6 +933,12 @@ def iwait(objects, timeout=None, count=None):
are available, then this method returns immediately.
.. seealso:: :func:`wait`
.. versionchanged:: 1.1a1
Add the *count* parameter.
.. versionchanged:: 1.1a2
No longer raise :exc:`LoopExit` if our caller switches greenlets
in between items yielded by this function.
"""
# QQQ would be nice to support iterable here that can be generated slowly (why?)
if
objects
is
None
:
...
...
gevent/local.py
View file @
4780e09c
...
...
@@ -127,6 +127,12 @@ affects what we see:
11
>>> del mydata
.. versionchanged:: 1.1a2
Update the implementation to match Python 3.4 instead of Python 2.5.
This results in locals being eligible for garbage collection as soon
as their greenlet exits.
"""
from
copy
import
copy
...
...
@@ -225,6 +231,9 @@ def _patch(self):
class
local
(
object
):
"""
An object whose attributes are greenlet-local.
"""
__slots__
=
'_local__impl'
,
'__dict__'
def
__new__
(
cls
,
*
args
,
**
kw
):
...
...
gevent/lock.py
View file @
4780e09c
...
...
@@ -171,8 +171,12 @@ class DummySemaphore(object):
pass
def
acquire
(
self
,
blocking
=
True
,
timeout
=
None
):
"""A DummySemaphore can always be acquired immediately so this always
"""
A DummySemaphore can always be acquired immediately so this always
returns True and ignores its arguments.
.. versionchanged:: 1.1a1
Always return *true*.
"""
return
True
...
...
gevent/monkey.py
View file @
4780e09c
...
...
@@ -269,6 +269,9 @@ def patch_thread(threading=True, _threading_local=True, Event=False, logging=Tru
:class:`multiprocessing.Queue` or
:class:`concurrent.futures.ProcessPoolExecutor` (which uses a
``Queue``) will hang the process.
.. versionchanged:: 1.1b1
Add *logging* and *existing_locks* params.
"""
# Description of the hang:
# There is an incompatibility with patching 'thread' and the 'multiprocessing' module:
...
...
gevent/os.py
View file @
4780e09c
...
...
@@ -264,7 +264,7 @@ if hasattr(os, 'fork'):
Availability: POSIX.
.. versionadded:: 1.1
a3
.. versionadded:: 1.1
b1
"""
# XXX Does not handle tracing children
if
pid
<=
0
:
...
...
@@ -329,7 +329,7 @@ if hasattr(os, 'fork'):
Pass the builtin :func:`os.fork` function if you do not need to
initialize gevent in the child process.
.. versionadded:: 1.1
a3
.. versionadded:: 1.1
b1
.. seealso::
:func:`gevent.monkey.get_original` To access the builtin :func:`os.fork`.
"""
...
...
gevent/pool.py
View file @
4780e09c
...
...
@@ -365,6 +365,8 @@ class GroupMappingMixin(object):
.. versionchanged:: 1.1b3
Added the *maxsize* keyword parameter.
.. versionchanged:: 1.1a1
Accept multiple *iterables* to iterate in parallel.
"""
return
self
.
__imap
(
IMap
,
func
,
*
iterables
,
**
kwargs
)
...
...
gevent/pywsgi.py
View file @
4780e09c
...
...
@@ -742,7 +742,12 @@ class WSGIHandler(object):
self
.
_sendall
(
towrite
)
def
start_response
(
self
,
status
,
headers
,
exc_info
=
None
):
# .. versionchanged:: 1.1b5 handle header/status encoding here
"""
.. versionchanged:: 1.1b5
Pro-actively handle checking the encoding of the status line
and headers during this method. On Python 2, avoid some
extra encodings.
"""
if
exc_info
:
try
:
if
self
.
headers_sent
:
...
...
gevent/queue.py
View file @
4780e09c
...
...
@@ -59,7 +59,7 @@ class Queue(object):
size is infinite.
.. versionchanged:: 1.1b3
Queue
'
s now support :func:`len`; it behaves the same as :meth:`qsize`.
Queues now support :func:`len`; it behaves the same as :meth:`qsize`.
.. versionchanged:: 1.1b3
Multiple greenlets that block on a call to :meth:`put` for a full queue
will now be woken up to put their items into the queue in the order in which
...
...
@@ -404,9 +404,19 @@ class LifoQueue(Queue):
class
JoinableQueue
(
Queue
):
'''A subclass of :class:`Queue` that additionally has :meth:`task_done` and :meth:`join` methods.'''
"""
A subclass of :class:`Queue` that additionally has
:meth:`task_done` and :meth:`join` methods.
"""
def
__init__
(
self
,
maxsize
=
None
,
items
=
None
,
unfinished_tasks
=
None
):
"""
.. versionchanged:: 1.1a1
If *unfinished_tasks* is not given, then all the given *items*
(if any) will be considered unfinished.
"""
from
gevent.event
import
Event
Queue
.
__init__
(
self
,
maxsize
,
items
)
self
.
_cond
=
Event
()
...
...
@@ -454,7 +464,8 @@ class JoinableQueue(Queue):
self
.
_cond
.
set
()
def
join
(
self
,
timeout
=
None
):
'''Block until all items in the queue have been gotten and processed.
'''
Block until all items in the queue have been gotten and processed.
The count of unfinished tasks goes up whenever an item is added to the queue.
The count goes down whenever a consumer thread calls :meth:`task_done` to indicate
...
...
@@ -465,6 +476,9 @@ class JoinableQueue(Queue):
for all tasks to finish.
:return: ``True`` if all tasks have finished; if ``timeout`` was given and expired before
all tasks finished, ``False``.
.. versionchanged:: 1.1a1
Add the *timeout* parameter.
'''
return
self
.
_cond
.
wait
(
timeout
=
timeout
)
...
...
gevent/signal.py
View file @
4780e09c
...
...
@@ -66,6 +66,10 @@ def signal(signalnum, handler):
Use of ``SIG_IGN`` and ``SIG_DFL`` may also have race conditions
with libev child watchers and the :mod:`gevent.subprocess` module.
.. versionchanged:: 1.1rc2
Allow using ``SIG_IGN`` and ``SIG_DFL`` to reset and ignore ``SIGCHLD``.
However, this allows the possibility of a race condition.
"""
if
signalnum
!=
_signal
.
SIGCHLD
:
return
_signal_signal
(
signalnum
,
handler
)
...
...
gevent/subprocess.py
View file @
4780e09c
...
...
@@ -347,7 +347,13 @@ class Popen(object):
cwd
=
None
,
env
=
None
,
universal_newlines
=
False
,
startupinfo
=
None
,
creationflags
=
0
,
threadpool
=
None
,
**
kwargs
):
"""Create new Popen instance."""
"""Create new Popen instance.
:param kwargs: *Only* allowed under Python 3; under Python 2, any
unrecognized keyword arguments will result in a :exc:`TypeError`.
Under Python 3, keyword arguments can include ``pass_fds``, ``start_new_session``,
and ``restore_signals``.
"""
if
not
PY3
and
kwargs
:
raise
TypeError
(
"Got unexpected keyword arguments"
,
kwargs
)
...
...
@@ -562,6 +568,13 @@ class Popen(object):
:keyword timeout: Under Python 2, this is a gevent extension; if
given and it expires, we will raise :class:`gevent.timeout.Timeout`.
Under Python 3, this raises the standard :exc:`TimeoutExpired` exception.
.. versionchanged:: 1.1a2
Under Python 2, if the *timeout* elapses, raise the :exc:`gevent.timeout.Timeout`
exception. Previously, we silently returned.
.. versionchanged:: 1.1b5
Honor a *timeout* even if there's no way to communicate with the child
(stdin, stdout, and stderr are not pipes).
"""
greenlets
=
[]
if
self
.
stdin
:
...
...
@@ -649,6 +662,7 @@ class Popen(object):
None
if
stderr
is
None
else
stderr_value
or
b''
)
def
poll
(
self
):
"""Check if child process has terminated. Set and return :attr:`returncode` attribute."""
return
self
.
_internal_poll
()
if
PY3
:
...
...
@@ -927,6 +941,7 @@ class Popen(object):
#
def
rawlink
(
self
,
callback
):
# Not public documented, part of the link protocol
self
.
result
.
rawlink
(
linkproxy
(
callback
,
self
))
# XXX unlink
...
...
@@ -1258,7 +1273,7 @@ class Popen(object):
return
self
.
returncode
def
wait
(
self
,
timeout
=
None
):
"""Wait for child process to terminate. Returns
returncode
"""Wait for child process to terminate. Returns
:attr:`returncode`
attribute.
:keyword timeout: The floating point number of seconds to wait.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment