pax_global_header 0000666 0000000 0000000 00000000064 13413644233 0014515 g ustar 00root root 0000000 0000000 52 comment=6fb4d762d931f5bbb934ac7af1d5cf5ff289a466
gevent-1.4.0/ 0000775 0000000 0000000 00000000000 13413644233 0013007 5 ustar 00root root 0000000 0000000 gevent-1.4.0/.coveragerc 0000664 0000000 0000000 00000003014 13413644233 0015126 0 ustar 00root root 0000000 0000000 [run]
# In coverage 4.0b3, concurrency=gevent is exactly equivalent to
# concurrency=greenlet, except it causes coverage itself to import
# gevent. That messes up our coverage numbers for top-level
# statements, so we use greenlet instead. See https://github.com/gevent/gevent/pull/655#issuecomment-141198002
# See also .coveragerc-pypy
concurrency = greenlet
parallel = True
source = gevent
omit =
# This is for <= 2.7.8, which we don't test
src/gevent/_ssl2.py
src/gevent/libev/_corecffi_build.py
src/gevent/libuv/_corecffi_build.py
src/gevent/win32util.py
# having concurrency=greenlet means that the Queue class
# which is used from multiple real threads doesn't
# properly get covered.
src/gevent/_threading.py
# local.so sometimes gets included, and it can't be parsed
# as source, so it fails the whole process.
*.so
src/gevent/libev/*.so
src/gevent/libuv/*.so
src/gevent/resolver/*.so
[report]
# Coverage is run on Linux under cPython 2/3 and pypy
exclude_lines =
pragma: no cover
def __repr__
raise AssertionError
raise NotImplementedError
except ImportError:
if __name__ == .__main__.:
if sys.platform == 'win32':
if mswindows:
if is_windows:
if WIN:
self.fail
omit =
# local.so sometimes gets included, and it can't be parsed
# as source, so it fails the whole process.
# coverage 4.5 needs this specified here, 4.4.2 needed it in [run]
*.so
/tmp/test_*
# Third-party vendored code
src/gevent/_tblib.py
gevent-1.4.0/.coveragerc-pypy 0000664 0000000 0000000 00000001741 13413644233 0016132 0 ustar 00root root 0000000 0000000 [run]
# This is just like .coveragerc, but
# used for PyPy running. pypy doesn't support concurrency=greenlet
parallel = True
source = gevent
omit =
# This is for <= 2.7.8, which we don't test
src/gevent/_ssl2.py
src/gevent/libev/_corecffi_build.py
src/gevent/libuv/_corecffi_build.py
src/gevent/win32util.py
# having concurrency=greenlet means that the Queue class
# which is used from multiple real threads doesn't
# properly get covered.
src/gevent/_threading.py
test_*
# local.so sometimes gets included, and it can't be parsed
# as source, so it fails the whole process.
*.so
[report]
# Coverage is run on Linux under cPython 2/3 and pypy, so
# exclude branches that are windows specific or pypy
# specific
exclude_lines =
pragma: no cover
def __repr__
raise AssertionError
raise NotImplementedError
except ImportError:
if __name__ == .__main__.:
if sys.platform == 'win32':
if mswindows:
if is_windows:
gevent-1.4.0/.github/ 0000775 0000000 0000000 00000000000 13413644233 0014347 5 ustar 00root root 0000000 0000000 gevent-1.4.0/.github/ISSUE_TEMPLATE.md 0000664 0000000 0000000 00000001104 13413644233 0017050 0 ustar 00root root 0000000 0000000 * gevent version:
* Python version: Please be as specific as possible: "cPython 2.7.9 downloaded from python.org"
* Operating System: Please be as specific as possible: "Raspbian (Debian Linux 8.0 Linux 4.9.35-v7+ armv7l)"
### Description:
**REPLACE ME**: What are you trying to get done, what has happened, what went wrong, and what did you expect?
```
Remember to put tracebacks in literal blocks
```
### What I've run:
**REPLACE ME**: Paste short, self contained, correct example code (sscce.org), tracebacks, etc, here
```python
"Put python code in python blocks"
```
gevent-1.4.0/.gitignore 0000664 0000000 0000000 00000003356 13413644233 0015006 0 ustar 00root root 0000000 0000000 *.py[cod]
build/
.runtimes
.tox/
*.so
*.o
*.egg-info
gevent.*.[ch]
src/gevent/__pycache__
src/gevent/_semaphore.c
src/gevent/local.c
src/gevent/greenlet.c
src/gevent/_ident.c
src/gevent/_imap.c
src/gevent/event.c
src/gevent/_hub_local.c
src/gevent/_waiter.c
src/gevent/_tracer.c
src/gevent/queue.c
src/gevent/_hub_primitives.c
src/gevent/_greenlet_primitives.c
src/gevent/_abstract_linkable.c
src/gevent/libev/corecext.c
src/gevent/libev/corecext.h
src/gevent/libev/_corecffi.c
src/gevent/libev/_corecffi.o
src/gevent/resolver/cares.c
# Cython annotations
src/gevent/*.html
src/gevent/libev/*.html
src/gevent/resolver/*.html
Makefile.ext
MANIFEST
*_flymake.py
.coverage\.*
htmlcov/
.coverage
doc/_build
doc/__pycache__
# Artifacts of configuring in place
deps/c-ares/config.log
deps/c-ares/config.status
deps/c-ares/stamp-h1
deps/c-ares/stamp-h2
deps/c-ares/ares_build.h.orig
deps/c-ares/ares_config.h
deps/c-ares/ares_build.h
deps/c-ares/.libs
deps/c-ares/*.o
deps/c-ares/*.lo
deps/c-ares/*.la
deps/c-ares/.deps
deps/c-ares/acountry
deps/c-ares/adig
deps/c-ares/ahost
deps/c-ares/Makefile
deps/c-ares/libtool
deps/c-ares/libcares.pc
deps/c-ares/test/.deps
deps/c-ares/test/Makefile
deps/c-ares/test/config.log
deps/c-ares/test/config.status
deps/c-ares/test/libtool
deps/c-ares/test/stamp-h1
deps/libev/.deps
deps/libev/Makefile
deps/libev/config.log
deps/libev/config.h
deps/libev/config.status
deps/libev/libtool
deps/libev/stamp-h1
deps/libev/.libs
deps/libev/*.lo
deps/libev/*.la
deps/libev/*.o
deps/libuv/.deps
deps/libuv/Makefile
deps/libuv/config.log
deps/libuv/config.h
deps/libuv/config.status
deps/libduv/libtool
deps/libuv/stamp-h1
deps/libuv/.libs
deps/libuv/*.lo
deps/libuv/*.la
deps/libuv/*.o
# running setup.py on PyPy
config.h
configure-output.txt
gevent-1.4.0/.landscape.yml 0000664 0000000 0000000 00000007520 13413644233 0015546 0 ustar 00root root 0000000 0000000 doc-warnings: no # experimental, raises an exception
test-warnings: no
strictness: veryhigh
max-line-length: 160
# We don't use any of the auto-detected things, and
# auto-detection slows down startup
autodetect: false
requirements:
- dev-requirements.txt
python-targets:
- 2
# - 3 # landscape.io seems to fail if we run both py2 and py3?
ignore-paths:
- examples/webchat/
- deps/libuv/
- doc/
- build/
- deps/
- dist
- .eggs
# util creates lots of warnings. ideally they should be fixed,
# but that code doesn't change often
- util
# likewise with scripts
- scripts/
# This file has invalid syntax for Python 3, which is how
# landscape.io runs things...
- src/gevent/_util_py2.py
# ...and this file has invalid syntax for Python 2, which is how
# travis currently runs things. sigh.
- src/gevent/_socket3.py
# This is vendored with minimal changes
- src/gevent/_tblib.py
# likewise
- src/greentest/_six.py
# This triggers https://github.com/PyCQA/pylint/issues/846 on Travis,
# but the file is really small, so it's better to skip this one
# file than disable that whole check.
- src/gevent/core.py
# sadly, this one is complicated
- setup.py
# This crashes (infinite recursion) trying to get the mro() of a class that extends
# build_ext
- _setuputils.py
- src/greentest/getaddrinfo_module.py
ignore-patterns:
# disabled code
- ^src/greentest/xtest_.*py
# standard library code
- ^src/greentest/2.*
- ^src/greentest/3.*
# benchmarks that aren't used/changed much
- ^src/greentest/bench_.*py
pyroma:
run: true
mccabe:
# We have way too many violations of the complexity measure.
# We should enable this and fix them one at a time, but that's
# more refactoring than I want to do initially.
run: false
pyflakes:
disable:
# F821: undefined name; caught better by pylint, where it can be
# controlled for the whole file/per-line
- F821
# F401: unused import; same story
- F401
# F811: redefined function; same story
- F811
# F403: wildcard import; same story
- F403
pep8:
disable:
# N805: first arg should be self; fails on metaclasses and
# classmethods; pylint does a better job
- N805
# N802: function names should be lower-case; comes from Windows
# funcs and unittest-style asserts and factory funcs
- N802
# N801: class names should use CapWords
- N801
# N803: argument name should be lower-case; comes up with using
# the class name as a keyword-argument
- N803
# N813: camelCase imported as lowercase; socketcommon
- N813
# N806: variable in function should be lowercase; but sometimes we
# want constant-looking names, especially for closures
- N806
# N812: lowercase imported as non-lowercase; from greenlet import
# greenlet as RawGreenlet
- N812
# E261: at least two spaces before inline comment. Really? Who does
# that?
- E261
# E265: Block comment should start with "# ". This arises from
# commenting out individual lines of code.
- E265
# N806: variable in function should be lowercase; but sometimes we
# want constant-looking names, especially for closures
- N806
# W503 line break before binary operator (I like and/or on the
# next line, it makes more sense)
- W503
# E266: too many leading '#' for block comment. (Multiple # can
# set off blocks)
- E266
# E402 module level import not at top of file. (happens in
# setup.py, some test cases)
- E402
# E702: multiple expressions on one line semicolon
# (happens for monkey-patch))
- E702
# E731: do not assign a lambda expression, use a def
# simpler than a def sometimes, and prevents redefinition warnings
- E731
# E302/303: Too many/too few blank lines (between classes, etc)
# This is *really* nitpicky.
- E302
- E303
gevent-1.4.0/.pylintrc 0000664 0000000 0000000 00000010752 13413644233 0014661 0 ustar 00root root 0000000 0000000 [MASTER]
extension-pkg-whitelist=gevent.libuv._corecffi,gevent.libev._corecffi,gevent.local,gevent._ident
[MESSAGES CONTROL]
# Disable the message, report, category or checker with the given id(s). You
# can either give multiple identifier separated by comma (,) or put this option
# multiple time (only on the command line, not in the configuration file where
# it should appear only once).
# NOTE: comments must go ABOVE the statement. In Python 2, mixing in
# comments disables all directives that follow, while in Python 3, putting
# comments at the end of the line does the same thing (though Py3 supports
# mixing)
# invalid-name, ; We get lots of these, especially in scripts. should fix many of them
# protected-access, ; We have many cases of this; legit ones need to be examinid and commented, then this removed
# no-self-use, ; common in superclasses with extension points
# too-few-public-methods, ; Exception and marker classes get tagged with this
# exec-used, ; should tag individual instances with this, there are some but not too many
# global-statement, ; should tag individual instances
# multiple-statements, ; "from gevent import monkey; monkey.patch_all()"
# locally-disabled, ; yes, we know we're doing this. don't replace one warning with another
# cyclic-import, ; most of these are deferred imports
# too-many-arguments, ; these are almost always because that's what the stdlib does
# redefined-builtin, ; likewise: these tend to be keyword arguments like len= in the stdlib
# undefined-all-variable, ; XXX: This crashes with pylint 1.5.4 on Travis (but not locally on Py2/3
# ; or landscape.io on Py3). The file causing the problem is unclear. UPDATE: identified and disabled
# that file.
# see https://github.com/PyCQA/pylint/issues/846
# useless-suppression: the only way to avoid repeating it for specific statements everywhere that we
# do Py2/Py3 stuff is to put it here. Sadly this means that we might get better but not realize it.
# duplicate-code: Yeah, the compatibility ssl modules are much the same
# In pylint 1.8.0, inconsistent-return-statements are created for the wrong reasons.
# This code raises it, even though there's only one return (the implicit 'return None' is presumably
# what triggers it):
# def foo():
# if baz:
# return 1
# In Pylint 2dev1, needed for Python 3.7, we get spurious 'useless return' errors:
# @property
# def foo(self):
# return None # generates useless-return
disable=wrong-import-position,
wrong-import-order,
missing-docstring,
ungrouped-imports,
invalid-name,
protected-access,
no-self-use,
too-few-public-methods,
exec-used,
global-statement,
multiple-statements,
locally-disabled,
cyclic-import,
too-many-arguments,
redefined-builtin,
useless-suppression,
duplicate-code,
undefined-all-variable,
inconsistent-return-statements,
useless-return,
useless-object-inheritance
[FORMAT]
# duplicated from setup.cfg
max-line-length=160
max-module-lines=1100
[MISCELLANEOUS]
# List of note tags to take in consideration, separated by a comma.
#notes=FIXME,XXX,TODO
# Disable that, we don't want them in the report (???)
notes=
[VARIABLES]
dummy-variables-rgx=_.*
[TYPECHECK]
# List of members which are set dynamically and missed by pylint inference
# system, and so shouldn't trigger E1101 when accessed. Python regular
# expressions are accepted.
# gevent: this is helpful for py3/py2 code.
generated-members=exc_clear
# List of classes names for which member attributes should not be checked
# (useful for classes with attributes dynamically set). This supports can work
# with qualified names.
# greenlet, Greenlet, parent, dead: all attempts to fix issues in greenlet.py
# only seen on the service, e.g., self.parent.loop: class parent has no loop
ignored-classes=SSLContext, SSLSocket, greenlet, Greenlet, parent, dead
# List of module names for which member attributes should not be checked
# (useful for modules/projects where namespaces are manipulated during runtime
# and thus existing member attributes cannot be deduced by static analysis. It
# supports qualified module names, as well as Unix pattern matching.
ignored-modules=gevent._corecffi,gevent.os,os,greenlet,threading,gevent.libev.corecffi,gevent.socket,gevent.core
[DESIGN]
max-attributes=12
max-parents=10
[BASIC]
bad-functions=input
# Prospector turns ot unsafe-load-any-extension by default, but
# pylint leaves it off. This is the proximal cause of the
# undefined-all-variable crash.
#unsafe-load-any-extension = no
gevent-1.4.0/.travis.yml 0000664 0000000 0000000 00000002013 13413644233 0015114 0 ustar 00root root 0000000 0000000 # .travis.yml based on https://github.com/DRMacIver/hypothesis/blob/master/.travis.yml
language: python
dist: xenial
group: travis_latest
python:
- 3.7-dev
env:
global:
- BUILD_RUNTIMES=$HOME/.runtimes
- PYTHONHASHSEED=8675309
- CC="ccache gcc"
- CCACHE_NOCPP2=true
- CCACHE_SLOPPINESS=file_macro,time_macros,include_file_ctime,include_file_mtime
- CCACHE_NOHASHDIR=true
- CFLAGS="-g -pipe"
matrix:
# These are ordered to get as much diversity in the
# first group of parallel runs (4) as possible
- TASK=test-py37
- TASK=test-py27
- TASK=test-pypy
- TASK=test-py36
- TASK=test-py27-noembed
- TASK=test-pypy3
- TASK=test-py35
- TASK=test-py34
matrix:
fast_finish: true
script:
- make $TASK
notifications:
email: false
cache:
pip: true
directories:
- $HOME/.venv
- $HOME/.runtimes
- $HOME/.wheelhouse
- $HOME/.ccache
before_cache:
- rm -f $HOME/.cache/pip/log/debug.log
gevent-1.4.0/AUTHORS 0000664 0000000 0000000 00000002427 13413644233 0014064 0 ustar 00root root 0000000 0000000 Gevent is written and maintained by
Denis Bilenko
Matt Iversen
Steffen Prince
Jason Madden
and the contributors (ordered by the date of first contribution):
Jason Toffaletti
Mike Barton
Ludvig Ericson
Marcus Cavanaugh
Matt Goodall
Ralf Schmitt
Daniele Varrazzo
Nicholas Piël
Örjan Persson
Uriel Katz
Ted Suzman
Randall Leeds
Erik Näslund
Alexey Borzenkov
David Hain
Dmitry Chechik
Ned Rockson
Tommie Gannert
Shaun Lindsay
Andreas Blixt
Nick Barkas
Galfy Pundee
Alexander Boudkar
Damien Churchill
Tom Lynn
Shaun Cutts
David LaBissoniere
Alexandre Kandalintsev
Geert Jansen
Vitaly Kruglikov
Saúl Ibarra Corretgé
Oliver Beattie
Bobby Powers
Anton Patrushev
Jan-Philip Gehrcke
Alex Gaynor
陈小玉
Philip Conrad
Heungsub Lee
Ron Rothman
See https://github.com/gevent/gevent/graphs/contributors for more info.
Gevent is inspired by and uses some code from eventlet which was written by
Bob Ipollito
Donovan Preston
The win32util module is taken from Twisted. The tblib module is taken from python-tblib by Ionel Cristian Mărieș.
Some modules (local, ssl) contain code from the Python standard library.
If your code is used in gevent and you are not mentioned above, please contact the maintainer.
gevent-1.4.0/CHANGES.rst 0000664 0000000 0000000 00000077603 13413644233 0014626 0 ustar 00root root 0000000 0000000 ===========
Changelog
===========
.. currentmodule:: gevent
1.4.0 (2019-01-04)
==================
- Build with Cython 0.29 in '3str' mode.
- Test with PyPy 6.0 on Windows.
- Add support for application-wide callbacks when ``Greenlet`` objects
are started. See :pr:`1289`, provided by Yury Selivanov.
- Fix consuming a single ready object using
``next(gevent.iwait(objs))``. Previously such a construction would
hang because `iter` was not called. See :pr:`1288`, provided by Josh
Snyder. This is not recommended, though, as unwaited objects will
have dangling links (but see next item).
- Make `gevent.iwait` return an iterator that can now also be used as
a context manager. If you'll only be consuming part of the iterator,
use it in a ``with`` block to avoid leaking resources. See
:pr:`1290`, provided by Josh Snyder.
- Fix semaphores to immediately notify links if they are ready and
``rawlink()`` is called. This behaves like ``Event`` and
``AsyncEvent``. Note that the order in which semaphore links are
called is not specified. See :issue:`1287`, reported by Dan Milon.
- Improve safety of handling exceptions during interpreter shutdown.
See :issue:`1295` reported by BobDenar1212.
- Remove the deprecated ability to specify ``GEVENT_RESOLVER`` and
other importable settings as a ``path/to/a/package.module.item``.
This had race conditions and didn't work with complicated resolver
implementations. Place the required package or module on `sys.path`
first.
- Reduce the chances that using the blocking monitor functionality
could result in apparently random ``SystemError:
Objects/tupleobject.c: bad argument to internal function``. Reported
in :issue:`1302` by Ulrich Petri.
- Refactored the gevent test runner and test suite to make them more
reusable. In particular, the tests are now run with ``python -m
gevent.tests``. See :issue:`1293`.
- Make a monkey-patched ``socket.getaddrinfo`` return socket module
enums instead of plain integers for the socket type and address
family on Python 3. See :issue:`1310` reported by TheYOSH.
- Make gevent's pywsgi server set the non-standard environment value
``wsgi.input_terminated`` to True. See :issue:`1308`.
- Make `gevent.util.assert_switches` produce more informative messages
when the assertion fails.
- Python 2: If a `gevent.socket` was closed asynchronously (in a
different greenlet or a hub callback), `AttributeError` could result
if the socket was already in use. Now the correct socket.error
should be raised.
- Fix :meth:`gevent.threadpool.ThreadPool.join` raising a
`UserWarning` when using the libuv backend. Reported in
:issue:`1321` by ZeroNet.
- Fix ``FileObjectPosix.seek`` raising `OSError` when it should have
been `IOError` on Python 2. Reported by, and PR by, Ricardo Kirkner.
See :issue:`1323`.
- Upgrade libuv from 1.23.2 to 1.24.0.
1.3.7 (2018-10-12)
==================
- Formatting run info no longer includes ``gevent.local.local``
objects that have no value in the greenlet. See :issue:`1275`.
- Fixed negative length in pywsgi's Input read functions for non chunked body.
Reported in :issue:`1274` by tzickel.
- Upgrade libuv from 1.22.0 to 1.23.2.
- Fix opening files in text mode in CPython 2 on Windows by patching
libuv. See :issue:`1282` reported by wiggin15.
1.3.6 (2018-08-17)
==================
- gevent now depends on greenlet 0.4.14 or above. gevent binary wheels
for 1.3.5 and below must have greenlet 0.4.13 installed on Python
3.7 or they will crash. Reported by Alexey Stepanov in :issue:`1260`
and pkittenis in :issue:`1261`.
- :class:`gevent.local.local` subclasses correctly supports
``@staticmethod`` functions. Reported by Brendan Powers in
:issue:`1266`.
1.3.5 (2018-07-16)
==================
- Update the bundled libuv from 1.20.1 to 1.22.0.
- Test Python 3.7 on Appveyor. Fix the handling of Popen's
``close_fds`` argument on 3.7.
- Update Python versions tested on Travis, including PyPy to 6.0. See :issue:`1195`.
- :mod:`gevent.queue` imports ``_PySimpleQueue`` instead of
``SimpleQueue`` so that it doesn't block the event loop.
:func:`gevent.monkey.patch_all` makes this same substitution in
:mod:`queue`. This fixes issues with
:class:`concurrent.futures.ThreadPoolExecutor` as well. Reported in
:issue:`1248` by wwqgtxx and :issue:`1251` by pyld.
- :meth:`gevent.socket.socket.connect` doesn't pass the port (service)
to :func:`socket.getaddrinfo` when it resolves an ``AF_INET`` or
``AF_INET6`` address. (The standard library doesn't either.) This
fixes an issue on Solaris. Reported in :issue:`1252` by wiggin15.
- :meth:`gevent.socket.socket.connect` works with more address
families, notably AF_TIPC, AF_NETLINK, AF_BLUETOOTH, AF_ALG and AF_VSOCK.
1.3.4 (2018-06-20)
==================
- Be more careful about issuing ``MonkeyPatchWarning`` for ssl
imports. Now, we only issue it if we detect the one specific
condition that is known to lead to RecursionError. This may produce
false negatives, but should reduce or eliminate false positives.
- Based on measurements and discussion in :issue:`1233`, adjust the
way :mod:`gevent.pywsgi` generates HTTP chunks. This is intended to
reduce network overhead, especially for smaller chunk sizes.
- Additional slight performance improvements in :mod:`gevent.pywsgi`.
See :pr:`1241`.
1.3.3 (2018-06-08)
==================
- :func:`gevent.sleep` updates the loop's notion of the current time
before sleeping so that sleep duration corresponds more closely to
elapsed (wall clock) time. :class:`gevent.Timeout` does the same.
Reported by champax and FoP in :issue:`1227`.
- Fix an ``UnboundLocalError`` in SSL servers when wrapping a socket
throws an error. Reported in :issue:`1236` by kochelmonster.
1.3.2.post0 (2018-05-30)
========================
- Fix a packaging error in manylinux binary wheels that prevented some
imports from working. See :issue:`1219`.
1.3.2 (2018-05-29)
==================
- Allow weak refeneces to :class:`gevent.queue.Queue`. Reported in
:issue:`1217` by githrdw.
1.3.1 (2018-05-18)
==================
- Allow weak references to :class:`gevent.event.Event`. Reported in
:issue:`1211` by Matias Guijarro.
- Fix embedded uses of :func:`gevent.Greenlet.spawn`, especially under
uwsgi. Reported in :issue:`1212` by Kunal Gangakhedkar.
- Fix :func:`gevent.os.nb_write` and :func:`gevent.os.nb_read` not
always closing the IO event they opened in the event of an
exception. This would be a problem especially for libuv.
1.3.0 (2018-05-11)
==================
- Python 3.7 passes the automated memory leak checks. See :issue:`1197`.
- Update autoconf's config.guess and config.sub to the latest versions
for c-ares and libev.
- :class:`gevent.local.local` subclasses that mix-in ABCs can be instantiated.
Reported in :issue:`1201` by Bob Jordan.
1.3b2 (2018-05-03)
==================
- On Windows, CFFI is now a dependency so that the libuv backend
really can be used by default.
- Fix a bug detecting whether we can use the memory monitoring
features when psutil is not installed.
- `gevent.subprocess.Popen` uses ``/proc/self/fd`` (on Linux) or
``/dev/fd`` (on BSD, including macOS) to find the file descriptors
to close when ``close_fds`` is true. This matches an optimization
added to Python 3 (and backports it to Python 2.7), making process
spawning up to 9 times faster. Also, on Python 3, since Python 3.3
is no longer supported, we can also optimize the case where
``close_fds`` is false (not the default), making process spawning up
to 38 times faster. Initially reported in :issue:`1172` by Ofer Koren.
- The bundled libuv is now 1.20.1, up from 1.19.2. See :issue:`1177`.
- The long-deprecated and undocumented module ``gevent.wsgi`` was removed.
- Add `gevent.util.assert_switches` to build on the monitoring
functions. Fixes :issue:`1182`.
- A started monitor thread for the active hub now survives a fork. See
:issue:`1185`.
- The greenlet tracer functions used for the various monitoring
capabilities are now compiled with Cython for substantially lower
overhead. See :pr:`1190`.
- libuv now collects all pending watchers and runs their callbacks at
the end of the loop iteration using UV_RUN_ONCE. This eliminates the
need to patch libuv to be greenlet-safe. It also means that
zero-duration timer watchers are actual timer watchers again
(instead of being turned into check watchers); newly added
zero-duration timers cannot block the event loop because they won't
be run until a safe time.
- Python 3.7.0b4 is now the tested and supported version of Python
3.7. PyPy 6.0 has been tested, although CI continues to use 5.10.
1.3b1 (2018-04-13)
==================
Dependencies
------------
- Cython 0.28.2 is now used to build gevent from a source checkout.
- The bundled libuv is now 1.19.2, up from 1.18.0.
Platform Support
----------------
- Travis CI tests on Python 3.7.0b3.
- Windows now defaults to the libuv backend if CFFI is installed. See
:issue:`1163`.
Bug Fixes
---------
- On Python 2, when monkey-patching `threading.Event`, also
monkey-patch the underlying class, ``threading._Event``. Some code
may be type-checking for that. See :issue:`1136`.
- Fix libuv io watchers polling for events that only stopped watchers
are interested in, reducing CPU usage. Reported in :issue:`1144` by
wwqgtxx.
Enhancements
------------
- Add additional optimizations for spawning greenlets, making it
faster than 1.3a2.
- Use strongly typed watcher callbacks in the libuv CFFI extensions.
This prevents dozens of compiler warnings.
- When gevent prints a timestamp as part of an error message, it is
now in UTC format as specified by RFC3339.
- Threadpool threads that exit now always destroy their hub (if one
was created). This prevents some forms of resource leaks (notably
visible as blocking functions reported by the new monitoring abilities).
- Hub objects now include the value of their ``name`` attribute in
their repr.
- Pools for greenlets and threads have lower overhead, especially for
``map``. See :pr:`1153`.
- The undocumented, internal implementation classes ``IMap`` and
``IMapUnordered`` classes are now compiled with Cython, further
reducing the overhead of ``[Thread]Pool.imap``.
- The classes `gevent.event.Event` and `gevent.event.AsyncResult`
are compiled with Cython for improved performance, as is the
``gevent.queue`` module and ``gevent.hub.Waiter`` and certain
time-sensitive parts of the hub itself. Please report any
compatibility issues.
- ``python -m gevent.monkey
You're also welcome to join `#gevent`_ IRC channel on freenode.
Russian group
=============
Русскоязычная группа находится здесь: `Google Groups (gevent-ru)`_. Чтобы подписаться, отправьте сообщение на gevent-ru+subscribe@googlegroups.com
.. _Google Groups (gevent): http://groups.google.com/group/gevent
.. _#gevent: http://webchat.freenode.net/?channels=gevent
.. _Google Groups (gevent-ru): http://groups.google.com/group/gevent-ru
gevent-1.4.0/doc/conf.py 0000664 0000000 0000000 00000017630 13413644233 0015062 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
#
# gevent documentation build configuration file, created by
# sphinx-quickstart on Thu Oct 1 09:30:02 2009.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
from __future__ import print_function
import sys
import os
# Use the python versions instead of the cython compiled versions
# for better documentation extraction and ease of tweaking docs.
os.environ['PURE_PYTHON'] = '1'
sys.path.append(os.path.dirname(__file__)) # for mysphinxext
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.append(os.path.abspath('.'))
# -- General configuration -----------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.doctest',
'sphinx.ext.coverage',
'sphinx.ext.intersphinx',
'mysphinxext',
'sphinx.ext.extlinks',
'sphinx.ext.viewcode',
'repoze.sphinx.autointerface',
]
intersphinx_mapping = {
'http://docs.python.org/': None,
'https://greenlet.readthedocs.io/en/latest/': None,
'https://zopeevent.readthedocs.io/en/latest/': None,
'https://zopecomponent.readthedocs.io/en/latest/': None,
}
extlinks = {'issue': ('https://github.com/gevent/gevent/issues/%s',
'issue #'),
'pr': ('https://github.com/gevent/gevent/pull/%s',
'pull request #')}
autodoc_default_flags = ['members', 'show-inheritance']
autodoc_member_order = 'groupwise'
autoclass_content = 'both'
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8'
# The master toctree document.
master_doc = 'contents'
# General information about the project.
project = u'gevent'
copyright = u'2009-2018, gevent contributors'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
from gevent import __version__
version = __version__
# The full version, including alpha/beta/rc tags.
release = version
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of documents that shouldn't be included in the build.
#unused_docs = []
# List of directories, relative to source directory, that shouldn't be searched
# for source files.
exclude_trees = ['_build']
# The reST default role (used for this markup: `text`) to use for all documents.
default_role = 'obj'
# If true, '()' will be appended to :func: etc. cross-reference text.
add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
add_module_names = False
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'perldoc'
# A list of ignored prefixes for module index sorting.
modindex_common_prefix = ['gevent.']
# -- Options for HTML output ---------------------------------------------------
# The theme to use for HTML and HTML Help pages. Major themes that come with
# Sphinx are currently 'default' and 'sphinxdoc'.
html_theme = 'mytheme'
html_theme_path = ['.']
html_theme_options = {'gevent_version': __version__}
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#if html_theme == 'default':
# html_theme_options = {'rightsidebar' : True}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# " v documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
html_short_title = 'Documentation'
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
#html_static_path = ['_static']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
# This is true by default in sphinx 1.6
html_use_smartypants = True
smartquotes = True # 1.7
# Custom sidebar templates, maps document names to template names.
html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {'contentstable': 'contentstable.html'}
# If false, no module index is generated.
html_use_modindex = True
# If false, no index is generated.
html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
html_show_sourcelink = False
# If true, an OpenSearch description file will be output, and all pages will
# contain a tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = ''
# Output file base name for HTML help builder.
htmlhelp_basename = 'geventdoc'
# -- Options for LaTeX output --------------------------------------------------
# The paper size ('letter' or 'a4').
#latex_paper_size = 'letter'
# The font size ('10pt', '11pt' or '12pt').
#latex_font_size = '10pt'
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'gevent.tex', u'gevent Documentation',
u'gevent contributors', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# Additional stuff for the LaTeX preamble.
#latex_preamble = ''
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_use_modindex = True
###############################################################################
# prevent some stuff from showing up in docs
import socket
import gevent.socket
for item in gevent.socket.__all__[:]:
if getattr(gevent.socket, item) is getattr(socket, item, None):
gevent.socket.__all__.remove(item)
if not hasattr(gevent.socket, '_fileobject'):
# Python 3 building Python 2 docs.
gevent.socket._fileobject = object()
gevent-1.4.0/doc/configuration.rst 0000664 0000000 0000000 00000000330 13413644233 0017151 0 ustar 00root root 0000000 0000000 .. _gevent-configuration:
====================
Configuring gevent
====================
.. seealso:: :func:`gevent.setswitchinterval`
For additional runtime configuration.
.. autoclass:: gevent._config.Config
gevent-1.4.0/doc/contents.rst 0000664 0000000 0000000 00000001015 13413644233 0016140 0 ustar 00root root 0000000 0000000 ===================
Table Of Contents
===================
Introduction and Basics
=======================
.. toctree::
:maxdepth: 2
install
intro
whatsnew_1_3
api/gevent
api/gevent.greenlet
servers
dns
monitoring
loop_impls
configuration
changelog
API Details
===========
.. toctree::
:maxdepth: 2
api/index
Related Information
===================
.. toctree::
:maxdepth: 1
success
community
older_releases
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
gevent-1.4.0/doc/dns.rst 0000664 0000000 0000000 00000002446 13413644233 0015100 0 ustar 00root root 0000000 0000000 =======================
Name Resolution (DNS)
=======================
gevent includes support for a pluggable hostname resolution system.
Pluggable resolvers are (generally) intended to be cooperative.
This pluggable resolution system is used automatically when the system
is :mod:`monkey patched `, and may be used manually
through the :attr:`resolver attribute ` of the
:class:`gevent.hub.Hub` or the corresponding methods in the
:mod:`gevent.socket` module.
A resolver implements the 5 standandard functions from the
:mod:`socket` module for resolving hostnames and addresses:
* :func:`socket.gethostbyname`
* :func:`socket.gethostbyname_ex`
* :func:`socket.getaddrinfo`
* :func:`socket.gethostbyaddr`
* :func:`socket.getnameinfo`
Configuration
=============
gevent includes four implementations of resolvers, and applications
can provide their own implementation. By default, gevent uses
:class:`a threadpool `. This can
:attr:`be customized `.
Please see the documentation for each resolver class to understand the
relative performance and correctness tradeoffs.
.. toctree::
api/gevent.resolver.thread
api/gevent.resolver.ares
api/gevent.resolver.dnspython
api/gevent.resolver.blocking
gevent-1.4.0/doc/examples/ 0000775 0000000 0000000 00000000000 13413644233 0015372 5 ustar 00root root 0000000 0000000 gevent-1.4.0/doc/examples/concurrent_download.rst 0000664 0000000 0000000 00000000436 13413644233 0022200 0 ustar 00root root 0000000 0000000 ================================
Example concurrent_download.py
================================
.. literalinclude:: ../../examples/concurrent_download.py
:language: python
:linenos:
`Current source `_
gevent-1.4.0/doc/examples/dns_mass_resolve.rst 0000664 0000000 0000000 00000000417 13413644233 0021474 0 ustar 00root root 0000000 0000000 =============================
Example dns_mass_resolve.py
=============================
.. literalinclude:: ../../examples/dns_mass_resolve.py
:language: python
:linenos:
`Current source `_
gevent-1.4.0/doc/examples/echoserver.rst 0000664 0000000 0000000 00000000375 13413644233 0020276 0 ustar 00root root 0000000 0000000 =============================
Example echoserver.py
=============================
.. literalinclude:: ../../examples/echoserver.py
:language: python
:linenos:
`Current source `_
gevent-1.4.0/doc/examples/geventsendfile.rst 0000664 0000000 0000000 00000000411 13413644233 0021122 0 ustar 00root root 0000000 0000000 =============================
Example geventsendfile.py
=============================
.. literalinclude:: ../../examples/geventsendfile.py
:language: python
:linenos:
`Current source `_
gevent-1.4.0/doc/examples/index.rst 0000664 0000000 0000000 00000001465 13413644233 0017241 0 ustar 00root root 0000000 0000000 ==========
Examples
==========
..
All files generated with shell oneliner:
for i in examples/*py; do bn=`basename $i`; bnp=`basename $i .py`; echo -e "=============================\nExample $bn\n=============================\n.. literalinclude:: ../../examples/$bn\n :language: python\n :linenos:\n\n\`Current source \`_\n" > doc/examples/$bnp.rst; done
This is a snapshot of the examples contained in `the gevent source
`_.
.. toctree::
concurrent_download
dns_mass_resolve
echoserver
geventsendfile
portforwarder
processes
psycopg2_pool
threadpool
udp_client
udp_server
unixsocket_client
unixsocket_server
webproxy
webpy
wsgiserver
wsgiserver_ssl
gevent-1.4.0/doc/examples/portforwarder.rst 0000664 0000000 0000000 00000000406 13413644233 0021024 0 ustar 00root root 0000000 0000000 =============================
Example portforwarder.py
=============================
.. literalinclude:: ../../examples/portforwarder.py
:language: python
:linenos:
`Current source `_
gevent-1.4.0/doc/examples/processes.rst 0000664 0000000 0000000 00000000372 13413644233 0020134 0 ustar 00root root 0000000 0000000 =============================
Example processes.py
=============================
.. literalinclude:: ../../examples/processes.py
:language: python
:linenos:
`Current source `_
gevent-1.4.0/doc/examples/psycopg2_pool.rst 0000664 0000000 0000000 00000000406 13413644233 0020723 0 ustar 00root root 0000000 0000000 =============================
Example psycopg2_pool.py
=============================
.. literalinclude:: ../../examples/psycopg2_pool.py
:language: python
:linenos:
`Current source `_
gevent-1.4.0/doc/examples/threadpool.rst 0000664 0000000 0000000 00000000375 13413644233 0020272 0 ustar 00root root 0000000 0000000 =============================
Example threadpool.py
=============================
.. literalinclude:: ../../examples/threadpool.py
:language: python
:linenos:
`Current source `_
gevent-1.4.0/doc/examples/udp_client.rst 0000664 0000000 0000000 00000000375 13413644233 0020257 0 ustar 00root root 0000000 0000000 =============================
Example udp_client.py
=============================
.. literalinclude:: ../../examples/udp_client.py
:language: python
:linenos:
`Current source `_
gevent-1.4.0/doc/examples/udp_server.rst 0000664 0000000 0000000 00000000375 13413644233 0020307 0 ustar 00root root 0000000 0000000 =============================
Example udp_server.py
=============================
.. literalinclude:: ../../examples/udp_server.py
:language: python
:linenos:
`Current source `_
gevent-1.4.0/doc/examples/unixsocket_client.rst 0000664 0000000 0000000 00000000422 13413644233 0021654 0 ustar 00root root 0000000 0000000 =============================
Example unixsocket_client.py
=============================
.. literalinclude:: ../../examples/unixsocket_client.py
:language: python
:linenos:
`Current source `_
gevent-1.4.0/doc/examples/unixsocket_server.rst 0000664 0000000 0000000 00000000422 13413644233 0021704 0 ustar 00root root 0000000 0000000 =============================
Example unixsocket_server.py
=============================
.. literalinclude:: ../../examples/unixsocket_server.py
:language: python
:linenos:
`Current source `_
gevent-1.4.0/doc/examples/webproxy.rst 0000664 0000000 0000000 00000000367 13413644233 0020011 0 ustar 00root root 0000000 0000000 =============================
Example webproxy.py
=============================
.. literalinclude:: ../../examples/webproxy.py
:language: python
:linenos:
`Current source `_
gevent-1.4.0/doc/examples/webpy.rst 0000664 0000000 0000000 00000000356 13413644233 0017256 0 ustar 00root root 0000000 0000000 =============================
Example webpy.py
=============================
.. literalinclude:: ../../examples/webpy.py
:language: python
:linenos:
`Current source `_
gevent-1.4.0/doc/examples/wsgiserver.rst 0000664 0000000 0000000 00000000375 13413644233 0020331 0 ustar 00root root 0000000 0000000 =============================
Example wsgiserver.py
=============================
.. literalinclude:: ../../examples/wsgiserver.py
:language: python
:linenos:
`Current source `_
gevent-1.4.0/doc/examples/wsgiserver_ssl.rst 0000664 0000000 0000000 00000000411 13413644233 0021201 0 ustar 00root root 0000000 0000000 =============================
Example wsgiserver_ssl.py
=============================
.. literalinclude:: ../../examples/wsgiserver_ssl.py
:language: python
:linenos:
`Current source `_
gevent-1.4.0/doc/index.rst 0000664 0000000 0000000 00000001713 13413644233 0015417 0 ustar 00root root 0000000 0000000 =================
What is gevent?
=================
.. include:: _about.rst
:ref:`Continue reading ` »
If you like gevent, :doc:`donate ` to support the development.
What are others saying?
=======================
Mailing List
------------
.. raw:: html
.. _coroutine: https://en.wikipedia.org/wiki/Coroutine
.. _Python: http://python.org
.. _greenlet: https://greenlet.readthedocs.io
.. _libev: http://software.schmorp.de/pkg/libev.html
.. _libuv: http://libuv.org
gevent-1.4.0/doc/install.rst 0000664 0000000 0000000 00000020201 13413644233 0015747 0 ustar 00root root 0000000 0000000 ===============================
Installation and Requirements
===============================
.. _installation:
..
This file is included in README.rst so it is limited to plain
ReST markup, not Sphinx.
Supported Platforms
===================
`gevent 1.3`_ runs on Python 2.7 and Python 3. Releases 3.4, 3.5 and
3.6 of Python 3 are supported. (Users of older versions of Python 2
need to install gevent 1.0.x (2.5), 1.1.x (2.6) or 1.2.x (<=2.7.8);
gevent 1.2 can be installed on Python 3.3.) gevent requires the
`greenlet `_ library and will install
the `cffi`_ library by default on Windows.
gevent 1.3 also runs on PyPy 5.5 and above, although 5.9 or above is
strongly recommended. On PyPy, there are no external dependencies.
gevent is tested on Windows, OS X, and Linux, and should run on most
other Unix-like operating systems (e.g., FreeBSD, Solaris, etc.)
.. note:: On Windows using the libev backend, gevent is
limited to a maximum of 1024 open sockets due to
`limitations in libev`_. This limitation should not exist
with the default libuv backend.
Installation
============
.. note::
This section is about installing released versions of gevent
as distributed on the `Python Package Index`_
.. _Python Package Index: http://pypi.org/project/gevent
gevent and greenlet can both be installed with `pip`_, e.g., ``pip
install gevent``. Installation using `buildout
`_ is also supported.
On Windows, OS X, and Linux, both gevent and greenlet are
distributed as binary `wheels`_.
.. tip::
You need Pip 8.0 or later, or buildout 2.10.0 to install the
binary wheels.
.. tip::
On Linux, you'll need to install gevent from source if you wish to
use the libuv loop implementation. This is because the `manylinux1
`_ specification for the
distributed wheels does not support libuv. The `cffi`_ library
*must* be installed at build time.
Installing From Source
----------------------
If you are unable to use the binary wheels (for platforms where no
pre-built wheels are available or if wheel installation is disabled,
e.g., for libuv support on Linux), here are some things you need to know.
- You can install gevent from source with ``pip install --no-binary
gevent gevent``.
- You'll need a working C compiler that can build Python extensions.
On some platforms, you may need to install Python development
packages.
- Installing from source requires ``setuptools``. This is installed
automatically in virtual environments and by buildout. However,
gevent uses :pep:`496` environment markers in ``setup.py``.
Consequently, you'll need a version of setuptools newer than 25
(mid 2016) to install gevent from source; a version that's too old
will produce a ``ValueError``. Older versions of pipenv may also
`have issues installing gevent for this reason
`_.
- To build the libuv backend (which is required on Windows and
optional elsewhere), or the CFFI-based libev backend, you must
install `cffi`_ before attempting to install gevent on CPython (on
PyPy this step is not necessary).
Common Installation Issues
--------------------------
The following are some common installation problems and solutions for
those compiling gevent from source.
- Some Linux distributions are now mounting their temporary
directories with the ``noexec`` option. This can cause a standard
``pip install gevent`` to fail with an error like ``cannot run C
compiled programs``. One fix is to mount the temporary directory
without that option. Another may be to use the ``--build`` option to
``pip install`` to specify another directory. See `issue #570
`_ and `issue #612
`_ for examples.
- Also check for conflicts with environment variables like ``CFLAGS``. For
example, see `Library Updates `_.
- Users of a recent SmartOS release may need to customize the
``CPPFLAGS`` (the environment variable containing the default
options for the C preprocessor) if they are using the libev shipped
with gevent. See `Operating Systems
`_
for more information.
- If you see ``ValueError: ("Expected ',' or end-of-list in", "cffi >=
1.11.5 ; sys_platform == 'win32' and platform_python_implementation
== 'CPython'", 'at', " ; sys_platform == 'win32' and
platform_python_implementation == 'CPython'")``, the version of
setuptools is too old. Install a more recent version of setuptools.
Extra Dependencies
==================
gevent has no runtime dependencies outside the standard library,
greenlet and (on some platforms) `cffi`_. However, there are a
number of additional libraries that extend gevent's functionality and
will be used if they are available.
The `psutil `_ library is needed to
monitor memory usage.
`zope.event `_ is highly
recommended for configurable event support; it can be installed with
the ``events`` extra, e.g., ``pip install gevent[events]``.
`dnspython `_ is required for the
new pure-Python resolver, and on Python 2, so is `idna
`_. They can be installed with the
``dnspython`` extra.
Development
===========
To install the latest development version::
pip install setuptools cffi 'cython>=0.28' git+git://github.com/gevent/gevent.git#egg=gevent
.. note::
You will not be able to run gevent's test suite using that method.
To hack on gevent (using a virtualenv)::
$ git clone https://github.com/gevent/gevent.git
$ cd gevent
$ virtualenv env
$ source env/bin/activate
(env) $ pip install -r dev-requirements.txt
.. note::
The notes above about installing from source apply here as well.
The ``dev-requirements.txt`` file takes care of the library
prerequisites (CFFI, Cython), but having a working C compiler that
can create Python extensions is up to you.
Running Tests
-------------
There are a few different ways to run the tests. To simply run the
tests on one version of Python during development, begin with the
above instructions to install gevent in a virtual environment and then
run::
(env) $ python -mgevent.tests
Before submitting a pull request, it's a good idea to run the tests
across all supported versions of Python, and to check the code quality
using prospector. This is what is done on Travis CI. Locally it
can be done using tox::
pip install tox
tox
The testrunner accepts a ``--coverage`` argument to enable code
coverage metrics through the `coverage.py`_ package. That would go
something like this::
python -m gevent.tests --coverage
coverage combine
coverage html -i
Continuous integration
----------------------
A test suite is run for every push and pull request submitted. Travis
CI is used to test on Linux, and `AppVeyor`_ runs the builds on
Windows.
.. image:: https://travis-ci.org/gevent/gevent.svg?branch=master
:target: https://travis-ci.org/gevent/gevent
.. image:: https://ci.appveyor.com/api/projects/status/q4kl21ng2yo2ixur?svg=true
:target: https://ci.appveyor.com/project/denik/gevent
Builds on Travis CI automatically submit updates to `coveralls.io`_ to
monitor test coverage.
.. image:: https://coveralls.io/repos/gevent/gevent/badge.svg?branch=master&service=github
:target: https://coveralls.io/github/gevent/gevent?branch=master
.. note:: On Debian, you will probably need ``libpythonX.Y-testsuite``
installed to run all the tests.
.. _coverage.py: https://pypi.python.org/pypi/coverage/
.. _coveralls.io: https://coveralls.io/github/gevent/gevent
.. _`pip`: https://pip.pypa.io/en/stable/installing/
.. _`wheels`: http://pythonwheels.com
.. _`gevent 1.3`: whatsnew_1_3.html
.. _`cffi`: https://cffi.readthedocs.io
.. _`limitations in libev`: http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod#WIN32_PLATFORM_LIMITATIONS_AND_WORKA
.. _AppVeyor: https://ci.appveyor.com/project/denik/gevent
gevent-1.4.0/doc/intro.rst 0000664 0000000 0000000 00000030005 13413644233 0015437 0 ustar 00root root 0000000 0000000 ==============
Introduction
==============
.. include:: _about.rst
Example
=======
The following example shows how to run tasks concurrently.
>>> import gevent
>>> from gevent import socket
>>> urls = ['www.google.com', 'www.example.com', 'www.python.org']
>>> jobs = [gevent.spawn(socket.gethostbyname, url) for url in urls]
>>> gevent.joinall(jobs, timeout=2)
>>> [job.value for job in jobs]
['74.125.79.106', '208.77.188.166', '82.94.164.162']
After the jobs have been spawned, :func:`gevent.joinall` waits for
them to complete, allowing up to 2 seconds. The results are
then collected by checking the :attr:`~gevent.Greenlet.value` property.
The :func:`gevent.socket.gethostbyname` function has the same
interface as the standard :func:`socket.gethostbyname` but it does not
block the whole interpreter and thus lets the other greenlets proceed
with their requests unhindered.
.. _monkey-patching:
Monkey patching
===============
The example above used :mod:`gevent.socket` for socket operations. If the standard :mod:`socket`
module was used the example would have taken 3 times longer to complete because the DNS requests would
be sequential (serialized). Using the standard socket module inside greenlets makes gevent rather
pointless, so what about existing modules and packages that are built
on top of :mod:`socket` (including the standard library modules like :mod:`urllib`)?
That's where monkey patching comes in. The functions in :mod:`gevent.monkey` carefully
replace functions and classes in the standard :mod:`socket` module with their cooperative
counterparts. That way even the modules that are unaware of gevent can benefit from running
in a multi-greenlet environment.
>>> from gevent import monkey; monkey.patch_socket()
>>> import urllib2 # it's usable from multiple greenlets now
See :doc:`examples/concurrent_download`.
Beyond sockets
--------------
Of course, there are several other parts of the standard library that can
block the whole interpreter and result in serialized behavior. gevent
provides cooperative versions of many of those as well. They can be
patched independently through individual functions, but most programs
using monkey patching will want to patch the entire recommended set of
modules using the :func:`gevent.monkey.patch_all` function::
>>> from gevent import monkey; monkey.patch_all()
>>> import subprocess # it's usable from multiple greenlets now
.. tip::
When monkey patching, it is recommended to do so as early as
possible in the lifetime of the process. If possible,
monkey patching should be the first lines executed. Monkey
patching later, especially if native threads have been
created, :mod:`atexit` or signal handlers have been installed,
or sockets have been created, may lead to unpredictable
results including unexpected :exc:`~gevent.hub.LoopExit` errors.
Event loop
==========
Instead of blocking and waiting for socket operations to complete (a
technique known as polling), gevent arranges for the operating system
to deliver an event letting it know when, for example, data has
arrived to be read from the socket. Having done that, gevent can move
on to running another greenlet, perhaps one that itself now has an
event ready for it. This repeated process of registering for events
and reacting to them as they arrive is the event loop.
Unlike other network libraries, though in a similar fashion as
eventlet, gevent starts the event loop implicitly in a dedicated
greenlet. There's no ``reactor`` that you must call a ``run()`` or
``dispatch()`` function on. When a function from gevent's API wants to
block, it obtains the :class:`gevent.hub.Hub` instance --- a special
greenlet that runs the event loop --- and switches to it (it is said
that the greenlet *yielded* control to the Hub). If there's no
:class:`~gevent.hub.Hub` instance yet, one is automatically created.
.. tip:: Each operating system thread has its own
:class:`~gevent.hub.Hub`. This makes it possible to use the
gevent blocking API from multiple threads (with care).
The event loop uses the best polling mechanism available on the system
by default.
.. note::
A low-level event loop API is available under the
:mod:`gevent.core` module. This module is not documented, not meant
for general purpose usage, and its exact contents and semantics
change slightly depending on whether the libev or libuv event loop
is being used. The callbacks supplied to the event loop API are run
in the :class:`~gevent.hub.Hub` greenlet and thus cannot use the
synchronous gevent API. It is possible to use the asynchronous API
there, like :func:`gevent.spawn` and
:meth:`gevent.event.Event.set`.
Cooperative multitasking
========================
.. currentmodule:: gevent
The greenlets all run in the same OS thread and are scheduled
cooperatively. This means that until a particular greenlet gives up
control, (by calling a blocking function that will switch to the
:class:`~gevent.hub.Hub`), other greenlets won't get a chance to run.
This is typically not an issue for an I/O bound app, but one should be
aware of this when doing something CPU intensive, or when calling
blocking I/O functions that bypass the event loop.
.. tip:: Even some apparently cooperative functions, like
:func:`gevent.sleep`, can temporarily take priority over
waiting I/O operations in some circumstances.
Synchronizing access to objects shared across the greenlets is
unnecessary in most cases (because yielding control is usually
explict), thus traditional synchronization devices like the
:class:`gevent.lock.BoundedSemaphore`, :class:`gevent.lock.RLock` and
:class:`gevent.lock.Semaphore` classes, although present, aren't used very
often. Other abstractions from threading and multiprocessing remain
useful in the cooperative world:
- :class:`~event.Event` allows one to wake up a number of greenlets
that are calling :meth:`~event.Event.wait` method.
- :class:`~event.AsyncResult` is similar to :class:`~event.Event` but
allows passing a value or an exception to the waiters.
- :class:`~queue.Queue` and :class:`~queue.JoinableQueue`.
.. _greenlet-basics:
Lightweight pseudothreads
=========================
.. currentmodule:: gevent
New greenlets are spawned by creating a :class:`~Greenlet` instance
and calling its :meth:`start ` method. (The
:func:`gevent.spawn` function is a shortcut that does exactly that).
The :meth:`start ` method schedules a switch to
the greenlet that will happen as soon as the current greenlet gives up
control. If there is more than one active greenlet, they will be
executed one by one, in an undefined order as they each give up
control to the :class:`~gevent.hub.Hub`.
If there is an error during execution it won't escape the greenlet's
boundaries. An unhandled error results in a stacktrace being printed,
annotated by the failed function's signature and arguments:
>>> gevent.spawn(lambda : 1/0)
>>> gevent.sleep(1)
Traceback (most recent call last):
...
ZeroDivisionError: integer division or modulo by zero
> failed with ZeroDivisionError
The traceback is asynchronously printed to ``sys.stderr`` when the greenlet dies.
:class:`Greenlet` instances have a number of useful methods:
- :meth:`join ` -- waits until the greenlet exits;
- :meth:`kill ` -- interrupts greenlet's execution;
- :meth:`get ` -- returns the value returned by greenlet or re-raises the exception that killed it.
Greenlets can be subclassed with care. One use for this is to
customize the string printed after the traceback by subclassing the
:class:`~gevent.Greenlet` class and redefining its ``__str__`` method.
For more information, see :ref:`subclassing-greenlet`.
Greenlets can be killed synchronously from another greenlet. Killing
will resume the sleeping greenlet, but instead of continuing
execution, a :exc:`GreenletExit` will be raised.
>>> g = Greenlet(gevent.sleep, 4)
>>> g.start()
>>> g.kill()
>>> g.dead
True
The :exc:`GreenletExit` exception and its subclasses are handled
differently than other exceptions. Raising :exc:`~GreenletExit` is not
considered an exceptional situation, so the traceback is not printed.
The :exc:`~GreenletExit` is returned by :meth:`get
` as if it were returned by the greenlet, not
raised.
The :meth:`kill ` method can accept a custom exception to be raised:
>>> g = Greenlet.spawn(gevent.sleep, 5) # spawn() creates a Greenlet and starts it
>>> g.kill(Exception("A time to kill"))
Traceback (most recent call last):
...
Exception: A time to kill
Greenlet(5) failed with Exception
The :meth:`kill ` can also accept a *timeout*
argument specifying the number of seconds to wait for the greenlet to
exit. Note that :meth:`kill ` cannot guarantee
that the target greenlet will not ignore the exception (i.e., it might
catch it), thus it's a good idea always to pass a timeout to
:meth:`kill ` (otherwise, the greenlet doing the
killing will remain blocked forever).
.. tip:: The exact timing at which an exception is raised within a
target greenlet as the result of :meth:`kill
` is not defined. See that function's
documentation for more details.
.. caution::
Use care when killing greenlets, especially arbitrary
greenlets spawned by a library or otherwise executing code you are
not familiar with. If the code being executed is not prepared to
deal with exceptions, object state may be corrupted. For example,
if it has acquired a ``Lock`` but *does not* use a ``finally``
block to release it, killing the greenlet at the wrong time could
result in the lock being permanently locked::
def func():
# DON'T DO THIS
lock.acquire()
socket.sendall(data) # This could raise many exceptions, including GreenletExit
lock.release()
`This document
`_
describes a similar situation for threads.
Timeouts
========
Many functions in the gevent API are synchronous, blocking the current
greenlet until the operation is done. For example, :meth:`kill
` waits until the target greenlet is
:attr:`~gevent.Greenlet.dead` before returning [#f1]_. Many of
those functions can be made asynchronous by passing the keyword argument
``block=False``.
Furthermore, many of the synchronous functions accept a *timeout*
argument, which specifies a limit on how long the function can block
(examples include :meth:`gevent.event.Event.wait`,
:meth:`gevent.Greenlet.join`, :meth:`gevent.Greenlet.kill`,
:meth:`gevent.event.AsyncResult.get`, and many more).
The :class:`socket ` and :class:`SSLObject
` instances can also have a timeout, set by the
:meth:`settimeout ` method.
When these are not enough, the :class:`gevent.Timeout` class and
:func:`gevent.with_timeout` can be used to add timeouts to arbitrary
sections of (cooperative, yielding) code.
Further Reading
===============
To limit concurrency, use the :class:`gevent.pool.Pool` class (see
:doc:`examples/dns_mass_resolve`).
Gevent comes with TCP/SSL/HTTP/WSGI servers. See :doc:`servers`.
There are a number of configuration options for gevent. See
:ref:`gevent-configuration` for details. This document also explains how
to enable gevent's builtin monitoring and debugging features.
The objects in :mod:`gevent.util` may be helpful for monitoring and
debugging purposes.
See :doc:`api/index` for a complete API reference.
External resources
==================
`Gevent for working Python developer`__ is a comprehensive tutorial.
__ http://sdiehl.github.io/gevent-tutorial/
.. rubric:: Footnotes
.. [#f1] This was not the case before 0.13.0, :meth:`kill ` method in 0.12.2 and older was asynchronous by default.
.. LocalWords: Greenlets
gevent-1.4.0/doc/loop_impls.rst 0000664 0000000 0000000 00000022372 13413644233 0016471 0 ustar 00root root 0000000 0000000 =============================================
Event Loop Implementations: libuv and libev
=============================================
.. versionadded:: 1.3
gevent offers a choice of two event loop libraries (`libev`_ and
`libuv`_) and three event loop implementations. This document will
explore those implementations and compare them to each other.
Using A Non-Default Loop
========================
First, we will describe how to choose an event loop other than the
default loop for a given platform. This is done by setting the
``GEVENT_LOOP`` environment variable before starting the program, or
by setting :attr:`gevent.config.loop ` in
code.
.. important::
If you choose to configure the loop in Python code, it must be done
*immediately* after importing gevent and before any other gevent
imports or asynchronous operations are done, preferably at the top
of your program, right above monkey-patching (if done)::
import gevent
gevent.config.loop = "libuv"
Loop Implementations
====================
Here we will describe the available loop implementations.
+----------+-------+------------+------------+-----+--------------+---------+--------+
|Name |Library|Default |Interpreters|Age |Implementation|Build |Embedded|
| | | | | | |Status | |
+==========+=======+============+============+=====+==============+=========+========+
|libev |libev |CPython on |CPython only|7 |Cython |Default |Default;|
| | |non-Windows | |years| | |optional|
| | |platforms | | | | | |
+----------+-------+------------+------------+-----+--------------+---------+--------+
|libev-cffi|libev |PyPy on |CPython and |3 |CFFI |Optional;|Required|
| | |non-Windows |PyPy |years| |default | |
| | |platforms | | | | | |
+----------+-------+------------+------------+-----+--------------+---------+--------+
|libuv |libuv |All |CPython and |1 |CFFI |Optional;|Required|
| | |interpreters|PyPy |years| |default | |
| | |on Windows | | | | | |
+----------+-------+------------+------------+-----+--------------+---------+--------+
.. _libev-impl:
libev
-----
`libev`_ is a venerable event loop library that has been the default
in gevent since 1.0a1 in 2011 when it replaced libevent. libev has
existed since 2007.
.. note::
In the future, this Cython implementation may be deprecated to be
replaced with :ref:`libev-cffi`.
.. _libev-dev:
.. rubric:: Development and Source
libev is a stable library and does not change quickly. Changes are
accepted in the form of patches emailed to a mailing list. Due to its
age and its portability requirements, it makes heavy use of
preprocessor macros, which some may find hinders readability of the
source code.
.. _libev-plat:
.. rubric:: Platform Support
gevent tests libev on Linux, and macOS (previously it was also tested
on Windows). There is no known list of platforms officially supported
by libev, although FreeBSD, OpenBSD and Solaris/SmartOS have been
reported to work with gevent on libev at various points.
On Windows, libev has `many limitations
`_.
gevent relies on the Microsoft C runtime functions to map from Windows
socket handles to integer file descriptors for libev using a somewhat
complex mapping; this prevents the CFFI implementation from being
used (which in turn prevents PyPy from using libev on Windows).
There is no known public CI infrastructure for libev itself.
.. _libev-cffi:
libev-cffi
----------
This uses libev exactly as above, but instead of using Cython it uses
CFFI. That makes it suitable (and the default) for PyPy. It can also
make it easier to debug, since more details are preserved for
tracebacks.
.. note::
In the future, this CFFI implementation may become the default and replace
:ref:`libev-impl`.
.. rubric:: When To Use
On PyPy or when debugging.
libuv
-----
libuv is an event loop library developed since 2011 for the use of
node 0.5. It was originally a wrapper around libev on non-Windows
platforms and directly used the native Windows IOCP support on Windows
(this code was contributed by Microsoft). Now it has its own loop
implementation on all supported platforms.
libuv provides libev-like `"poll handles"
`_, and in gevent 1.3 that is
what gevent uses for IO. But libuv also provides higher-level
abstractions around read and write requests that may offer improved
performance. In the future, gevent might use those abstractions.
.. note::
In the future, this implementation may become the default on all
platforms.
.. rubric:: Development and Source
libuv is developed by the libuv organization on `github
`_. It has a large, active community
and is used in many popular projects including node.js.
The source code is written in a clean and consistent coding style,
potentially making it easier to read and debug.
.. rubric:: Platform Support
gevent tests libuv on Linux, Windows and macOS. libuv publishes an
extensive list of `supported platforms
`_
that are likely to work with gevent. libuv `maintains a public CI
infrastructure `_.
.. rubric:: When To Use libuv
- You want to use PyPy on Windows.
- You want to develop on Windows (Windows is not recommended for
production).
- You want to use an operating system not supported by libev such as
IBM i.
.. note::
Platforms other than Linux, macOS and Windows are not
tested by gevent.
.. _libuv-limits:
Limitations and Differences
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Because of its newness, and because of some design decisions inherent
in the library and the ecosystem, there are some limitations and
differences in the way gevent behaves using libuv compared to libev.
- libuv support is not available in the manylinux wheels uploaded to
PyPI. The manylinux specification requires glibc 2.5, while libuv
requires glibc 2.12. Install from source to access libuv on Linux
(e.g., pip's ``--no-binary`` option).
- Timers (such as ``gevent.sleep`` and ``gevent.Timeout``) only
support a resolution of 1ms (in practice, it's closer to 1.5ms).
Attempting to use something smaller will automatically increase it
to 1ms and issue a warning. Because libuv only supports millisecond
resolution by rounding a higher-precision clock to an integer number
of milliseconds, timers apparently suffer from more jitter.
- Using negative timeouts may behave differently from libev.
- libuv blocks delivery of all signals, so signals are handled using
an (arbitrary) 0.3 second timer. This means that signal handling
will be delayed by up to that amount, and that the longest the
event loop can sleep in the operating system's ``poll`` call is
that amount. Note that this is what gevent does for libev on
Windows too.
- libuv only supports one io watcher per file descriptor, whereas
libev and gevent have always supported many watchers using
different settings. The libev behaviour is emulated at the Python
level.
- Looping multiple times and expecting events for the same file
descriptor to be raised each time without any data being read or
written (as works with libev) does not appear to work correctly on
Linux when using ``gevent.select.poll`` or a monkey-patched
``selectors.PollSelector``.
- The build system does not support using a system libuv; the
embedded copy must be used. Using setuptools to compile libuv was
the most portable method found.
- If anything unexpected happens, libuv likes to ``abort()`` the
entire process instead of reporting an error. For example, closing
a file descriptor it is using in a watcher may cause the entire
process to be exited.
- The order in which timers and other callbacks are invoked may be
different than in libev. In particular, timers and IO callbacks
happen in a different order, and timers may easily be off by up to
half of the nominal 1ms resolution. See :issue:`1057`.
- There is no support for priorities within classes of watchers. libev
has some support for priorities and this is exposed in the low-level
gevent API, but it was never documented.
- Low-level ``fork`` and ``child`` watchers are not available. gevent
emulates these in Python on platforms that supply :func:`os.fork`.
Child watchers use ``SIGCHLD``, just as on libev, so the same
caveats apply.
- Low-level ``prepare`` watchers are not available. gevent uses
prepare watchers for internal purposes. If necessary, this could be
emulated in Python.
Performance
===========
In the various micro-benchmarks gevent has, performance among all three
loop implementations is roughly the same. There doesn't seem to be a
clear winner or loser.
.. _libev: http://software.schmorp.de/pkg/libev.html
.. _libuv: http://libuv.org
.. LocalWords: gevent libev cffi PyPy CFFI libuv FreeBSD CPython Cython
gevent-1.4.0/doc/make.bat 0000664 0000000 0000000 00000005777 13413644233 0015201 0 ustar 00root root 0000000 0000000 @ECHO OFF
REM Command file for Sphinx documentation
set SPHINXBUILD=sphinx-build
set BUILDDIR=_build
set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
if NOT "%PAPER%" == "" (
set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
)
if "%1" == "" goto help
if "%1" == "help" (
:help
echo.Please use `make ^` where ^ is one of
echo. html to make standalone HTML files
echo. dirhtml to make HTML files named index.html in directories
echo. pickle to make pickle files
echo. json to make JSON files
echo. htmlhelp to make HTML files and a HTML help project
echo. qthelp to make HTML files and a qthelp project
echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
echo. changes to make an overview over all changed/added/deprecated items
echo. linkcheck to check all external links for integrity
echo. doctest to run all doctests embedded in the documentation if enabled
goto end
)
if "%1" == "clean" (
for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
del /q /s %BUILDDIR%\*
goto end
)
if "%1" == "html" (
%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%/html.
goto end
)
if "%1" == "dirhtml" (
%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
goto end
)
if "%1" == "pickle" (
%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
echo.
echo.Build finished; now you can process the pickle files.
goto end
)
if "%1" == "json" (
%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
echo.
echo.Build finished; now you can process the JSON files.
goto end
)
if "%1" == "htmlhelp" (
%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
echo.
echo.Build finished; now you can run HTML Help Workshop with the ^
.hhp project file in %BUILDDIR%/htmlhelp.
goto end
)
if "%1" == "qthelp" (
%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
echo.
echo.Build finished; now you can run "qcollectiongenerator" with the ^
.qhcp project file in %BUILDDIR%/qthelp, like this:
echo.^> qcollectiongenerator %BUILDDIR%\qthelp\gevent.qhcp
echo.To view the help file:
echo.^> assistant -collectionFile %BUILDDIR%\qthelp\gevent.ghc
goto end
)
if "%1" == "latex" (
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
echo.
echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
goto end
)
if "%1" == "changes" (
%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
echo.
echo.The overview file is in %BUILDDIR%/changes.
goto end
)
if "%1" == "linkcheck" (
%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
echo.
echo.Link check complete; look for any errors in the above output ^
or in %BUILDDIR%/linkcheck/output.txt.
goto end
)
if "%1" == "doctest" (
%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
echo.
echo.Testing of doctests in the sources finished, look at the ^
results in %BUILDDIR%/doctest/output.txt.
goto end
)
:end
gevent-1.4.0/doc/monitoring.rst 0000664 0000000 0000000 00000007227 13413644233 0016503 0 ustar 00root root 0000000 0000000 ==============================================
Monitoring and Debugging gevent Applications
==============================================
gevent applications are often long-running server processes. Beginning
with version 1.3, gevent has special support for monitoring such
applications and getting visibility into them.
.. tip::
For some additional tools, see the comments on `issue 1021
`_.
The Monitor Thread
==================
gevent can be :attr:`configured
` to start a native thread to
watch over each hub it creates. Out of the box, that thread has
support to watch two things, but you can :func:`add your own functions
` to be
called periodically in this thread.
Blocking
--------
When the monitor thread is enabled, by default it will watch for
greenlets that block the event loop for longer than a
:attr:`configurable ` time
interval. When such a blocking greenlet is detected, it will print
:func:`a report ` to the hub's
:attr:`~gevent.hub.Hub.exception_stream`. It will also emit the
:class:`gevent.events.EventLoopBlocked` event.
.. seealso:: :func:`gevent.util.assert_switches`
For a scoped version of this.
Memory Usage
------------
Optionally, you can set a :attr:`memory limit
`. The monitor thread will
check the process's memory usage every
:attr:`~gevent._config.Config.memory_monitor_period` seconds, and if
it is found to exceed this value, the
:class:`gevent.events.MemoryUsageThresholdExceeded` event will be
emitted. If in the future memory usage declines below the configured
value, the :class:`gevent.events.MemoryUsageUnderThreshold` event will
be emitted.
.. important::
`psutil `_ must be
installed to monitor memory usage.
Visibility
==========
It is sometimes useful to get an overview of all existing greenlets
and their stack traces. The function
:func:`gevent.util.print_run_info` will collect this info and print it
(:func:`gevent.util.format_run_info` only collects and returns this
information). The greenlets are organized into a tree based on the
greenlet that spawned them.
The ``print_run_info`` function is commonly hooked up to a signal
handler to get the application state at any given time.
For each greenlet the following information is printed:
- Its current execution stack
- If it is not running, its termination status and
:attr:`gevent.Greenlet.value` or
:attr:`gevent.Greenlet.exception`
- The :attr:`stack at which it was spawned
`
- Its parent (usually the hub)
- Its :attr:`~gevent.Greenlet.minimal_ident`
- Its :attr:`~gevent.Greenlet.name`
- The :attr:`spawn tree locals `
(only for the root of the spawn tree).
- The dicts of all :class:`gevent.local.local` objects that are used
in the greenlet.
The greenlet tree itself is represented as an object that you can also
use for your own purposes: :class:`gevent.util.GreenletTree`.
Profiling
=========
The github repository `nylas/nylas-perftools
`_ has some
gevent-compatible profilers.
- ``stacksampler`` is a sampling profiler meant to be run in a
greenlet in your server process and exposes data through an HTTP
server; it is designed to be suitable for production usage.
- ``py2devtools`` is a greenlet-aware tracing profiler that outputs data
that can be used by the Chrome dev tools; it is intended for
developer usage.
.. LocalWords: greenlets gevent greenlet
gevent-1.4.0/doc/mysphinxext.py 0000664 0000000 0000000 00000005207 13413644233 0016532 0 ustar 00root root 0000000 0000000 from __future__ import print_function
from sphinx.ext.autodoc import cut_lines
from sphinx.ext import intersphinx
from docutils import nodes
noisy = 0
message_cache = set()
def missing_reference(app, env, node, contnode):
"""Search the index for missing references.
For example, resolve :class:`Event` to :class:`Event `"""
# XXX methods and functions resolved by this function miss their ()
if intersphinx.missing_reference(app, env, node, contnode) is not None:
# is there a better way to give intersphinx a bigger priority?
return
env = app.builder.env
type = node['reftype']
target = node['reftarget']
modname = node.get('py:module')
classname = node.get('py:class')
if modname and classname:
return
def new_reference(refuri, reftitle):
newnode = nodes.reference('', '')
newnode['refuri'] = refuri
newnode['reftitle'] = reftitle
newnode['py:class'] = 'external-xref'
newnode['classname'] = 'external-xref'
newnode.append(contnode)
msg = 'Resolved missing-reference: :%5s:`%s` -> %s' % (type, target, refuri)
if noisy >= 1 or msg not in message_cache:
print(msg)
message_cache.add(msg)
return newnode
if noisy >= 1:
print('Looking for %s' % [type, target, modname, classname])
print(node)
for docname, items in env.indexentries.items():
if noisy >= 2:
print(docname)
for _x in items:
if noisy >= 4:
print(_x)
(i_type, i_string, i_target, i_aliasname) = _x[:4]
if noisy >= 3:
print('---', [i_type, i_string, i_target, i_aliasname])
if i_aliasname.endswith(target):
stripped_aliasname = i_aliasname[len(docname):]
if stripped_aliasname:
assert stripped_aliasname[0] == '.', repr(stripped_aliasname)
stripped_aliasname = stripped_aliasname[1:]
if stripped_aliasname == target:
if noisy >= 1:
print('--- found %s %s in %s' % (type, target, i_aliasname))
return new_reference(docname + '.html#' + i_aliasname, i_aliasname)
if type == 'mod':
modules = [x for x in env.indexentries.keys() if x.startswith('gevent.')]
target = 'gevent.' + target
if target in modules:
return new_reference(target + '.html', target)
def setup(app):
app.connect('missing-reference', missing_reference)
app.connect('autodoc-process-docstring', cut_lines(2, what=['module']))
gevent-1.4.0/doc/mytheme/ 0000775 0000000 0000000 00000000000 13413644233 0015224 5 ustar 00root root 0000000 0000000 gevent-1.4.0/doc/mytheme/changes/ 0000775 0000000 0000000 00000000000 13413644233 0016634 5 ustar 00root root 0000000 0000000 gevent-1.4.0/doc/mytheme/changes/frameset.html 0000664 0000000 0000000 00000000624 13413644233 0021332 0 ustar 00root root 0000000 0000000
{% trans version=version|e, docstitle=docstitle|e %}Changes in Version {{ version }} — {{ docstitle }}{% endtrans %}
gevent-1.4.0/doc/mytheme/changes/rstsource.html 0000664 0000000 0000000 00000000647 13413644233 0021562 0 ustar 00root root 0000000 0000000
{% trans filename=filename, docstitle=docstitle|e %}{{ filename }} — {{ docstitle }}{% endtrans %}
{% trans %}Please activate JavaScript to enable the search
functionality.{% endtrans %}
{% trans %}From here you can search these documents. Enter your search
words into the box below and click "search". Note that the search
function will automatically search for all of the words. Pages
containing fewer words won't appear in the result list.{% endtrans %}
{% if search_performed %}
{{ _('Search Results') }}
{% if not search_results %}
{{ _('Your search did not match any results.') }}
{% endif %}
{% endif %}
{% if search_results %}
{% for href, caption, context in search_results %}