From 9791fefac619f29b5b2d095c20badd9485a9fc9a Mon Sep 17 00:00:00 2001 From: Ryan Williams Date: Sat, 2 Jan 2010 08:56:42 -0800 Subject: [PATCH] Consolidated tpool and threading documentation. --- doc/modules.rst | 1 - doc/modules/tpool.rst | 6 ------ doc/threading.rst | 12 ++++++++++-- 3 files changed, 10 insertions(+), 9 deletions(-) delete mode 100644 doc/modules/tpool.rst diff --git a/doc/modules.rst b/doc/modules.rst index efe6d3f..14f5bda 100644 --- a/doc/modules.rst +++ b/doc/modules.rst @@ -16,6 +16,5 @@ Module Reference modules/processes modules/proc modules/saranwrap - modules/tpool modules/util modules/wsgi diff --git a/doc/modules/tpool.rst b/doc/modules/tpool.rst deleted file mode 100644 index e4e6303..0000000 --- a/doc/modules/tpool.rst +++ /dev/null @@ -1,6 +0,0 @@ -:mod:`tpool` -- Thread pooling -================================ - -.. automodule:: eventlet.tpool - :members: - diff --git a/doc/threading.rst b/doc/threading.rst index de65ff8..758e3c5 100644 --- a/doc/threading.rst +++ b/doc/threading.rst @@ -1,5 +1,5 @@ -Using Eventlet with Threads -============================= +Threads +======== Eventlet is thread-safe and can be used in conjunction with normal Python threads. The way this works is that coroutines are confined to their 'parent' Python thread. It's like each thread contains its own little world of coroutines that can switch between themselves but not between coroutines in other threads. @@ -9,6 +9,11 @@ You can only communicate cross-thread using the "real" thread primitives and pip The vast majority of the times you'll want to use threads are to wrap some operation that is not "green", such as a C library that uses its own OS calls to do socket operations. The :mod:`~eventlet.tpool` module is provided to make these uses simpler. +The pyevent hub is not compatible with threads. + +Tpool - Simple thread pool +--------------------------- + The simplest thing to do with :mod:`~eventlet.tpool` is to :func:`~eventlet.tpool.execute` a function with it. The function will be run in a random thread in the pool, while the calling coroutine blocks on its completion:: >>> import thread @@ -20,3 +25,6 @@ The simplest thing to do with :mod:`~eventlet.tpool` is to :func:`~eventlet.tpoo running in new thread: True My default there are 20 threads in the pool, but you can configure this by setting the environment variable ``EVENTLET_THREADPOOL_SIZE`` to the desired pool size before importing tpool. + +.. automodule:: eventlet.tpool + :members: \ No newline at end of file