diff --git a/doc/basic_usage.rst b/doc/basic_usage.rst index fb18972..c7a68e1 100644 --- a/doc/basic_usage.rst +++ b/doc/basic_usage.rst @@ -31,6 +31,10 @@ Though Eventlet has many modules, much of the most-used stuff is accessible simp Suspends the current greenthread and allows others a chance to process. See :func:`sleep ` for more details. +.. autofunction:: eventlet.connect + +.. autofunction:: eventlet.listen + .. class:: eventlet.GreenPool Pools control concurrency. It's very common in applications to want to consume only a finite amount of memory, or to restrict the amount of connections that one part of the code holds open so as to leave more for the rest, or to behave consistently in the face of unpredictable input data. GreenPools provide this control. See :class:`GreenPool ` for more on how to use these. @@ -58,5 +62,6 @@ Though Eventlet has many modules, much of the most-used stuff is accessible simp Globally patches certain system modules to be greenthread-friendly. The keyword arguments afford some control over which modules are patched. If *all* is True, then all modules are patched regardless of the other arguments. If it's False, then the rest of the keyword arguments control patching of specific subsections of the standard library. Most patch the single module of the same name (os, time, select). The exceptions are socket, which also patches the ssl module if present; and thread, which patches thread, threading, and Queue. It's safe to call monkey_patch multiple times. For more information see :ref:`monkey-patch`. + These are the basic primitives of Eventlet; there are a lot more out there in the other Eventlet modules; check out the :doc:`modules`. diff --git a/doc/design_patterns.rst b/doc/design_patterns.rst index bcac55b..fdd8f5f 100644 --- a/doc/design_patterns.rst +++ b/doc/design_patterns.rst @@ -42,7 +42,6 @@ Server Pattern Here's a simple server-side example, a simple echo server:: import eventlet - from eventlet.green import socket def handle(client): while True: @@ -50,9 +49,7 @@ Here's a simple server-side example, a simple echo server:: if not c: break client.sendall(c) - server = socket.socket() - server.bind(('0.0.0.0', 6000)) - server.listen(50) + server = eventlet.listen(('0.0.0.0', 6000)) pool = eventlet.GreenPool(10000) while True: new_sock, address = server.accept() @@ -60,7 +57,7 @@ Here's a simple server-side example, a simple echo server:: The file :ref:`echo server example ` contains a somewhat more robust and complex version of this example. -``from eventlet.green import socket`` imports eventlet's socket module, which is just like the regular socket module, but cooperatively yielding. +``server = eventlet.listen(('0.0.0.0', 6000))`` uses a convenience function to create a listening socket. ``pool = eventlet.GreenPool(10000)`` creates a pool of green threads that could handle ten thousand clients. diff --git a/doc/modules/processes.rst b/doc/modules/processes.rst deleted file mode 100644 index 6ae5b15..0000000 --- a/doc/modules/processes.rst +++ /dev/null @@ -1,5 +0,0 @@ -:mod:`processes` -- Running child processes -============================================= - -.. automodule:: eventlet.processes - :members: diff --git a/doc/modules/saranwrap.rst b/doc/modules/saranwrap.rst deleted file mode 100644 index 0d328fd..0000000 --- a/doc/modules/saranwrap.rst +++ /dev/null @@ -1,83 +0,0 @@ -:mod:`saranwrap` -- Running code in separate processes -======================================================= - -This is a convenient way of bundling code off into a separate process. If you are using Python 2.6, the multiprocessing module probably suits your needs better than saranwrap will. - -The simplest way to use saranwrap is to wrap a module and then call functions on that module:: - - >>> from eventlet import saranwrap - >>> import time - >>> s_time = saranwrap.wrap(time) - >>> timeobj = s_time.gmtime(0) - >>> timeobj - saran:(1970, 1, 1, 0, 0, 0, 3, 1, 0) - >>> timeobj.tm_sec - 0 - -The objects so wrapped behave as if they are resident in the current process space, but every attribute access and function call is passed over a nonblocking pipe to the child process. For efficiency, it's best to make as few attribute calls as possible relative to the amount of work being delegated to the child process. - -.. automodule:: eventlet.saranwrap - :members: - - -Underlying Protocol -------------------- - -Saranwrap's remote procedure calls are achieved by intercepting the basic -getattr and setattr calls in a client proxy, which commnicates those -down to the server which will dispatch them to objects in it's process -space. - -The basic protocol to get and set attributes is for the client proxy -to issue the command:: - - getattr $id $name - setattr $id $name $value - - getitem $id $item - setitem $id $item $value - eq $id $rhs - del $id - -When the get returns a callable, the client proxy will provide a -callable proxy which will invoke a remote procedure call. The command -issued from the callable proxy to server is:: - - call $id $name $args $kwargs - -If the client supplies an id of None, then the get/set/call is applied -to the object(s) exported from the server. - -The server will parse the get/set/call, take the action indicated, and -return back to the caller one of:: - - value $val - callable - object $id - exception $excp - -To handle object expiration, the proxy will instruct the rpc server to -discard objects which are no longer in use. This is handled by -catching proxy deletion and sending the command:: - - del $id - -The server will handle this by removing clearing it's own internal -references. This does not mean that the object will necessarily be -cleaned from the server, but no artificial references will remain -after successfully completing. On completion, the server will return -one of:: - - value None - exception $excp - -The server also accepts a special command for debugging purposes:: - - status - -Which will be intercepted by the server to write back:: - - status {...} - -The wire protocol is to pickle the Request class in this file. The -request class is basically an action and a map of parameters. diff --git a/doc/modules/util.rst b/doc/modules/util.rst deleted file mode 100644 index d573682..0000000 --- a/doc/modules/util.rst +++ /dev/null @@ -1,6 +0,0 @@ -:mod:`util` -- Stdlib wrapping and compatibility functions -=========================================================== - -.. automodule:: eventlet.util - :members: - :undoc-members: diff --git a/doc/modules/wsgi.rst b/doc/modules/wsgi.rst index 9c69db4..c05485d 100644 --- a/doc/modules/wsgi.rst +++ b/doc/modules/wsgi.rst @@ -9,17 +9,13 @@ server package. One such package is `Spawning