More dinking around with the docs.
This commit is contained in:
15
doc/hubs.rst
15
doc/hubs.rst
@@ -20,15 +20,16 @@ There is one function that is of interest as regards hubs.
|
||||
|
||||
Use this to control which hub Eventlet selects. Call it with the name of the desired hub module. Make sure to do this before the application starts doing any I/O! Calling use_hub completely eliminates the old hub, and any file descriptors or timers that it had been managing will be forgotten. Put the call as one of the first lines in the main module.::
|
||||
|
||||
""" my main module using eventlet """
|
||||
from eventlet import hubs
|
||||
hubs.use_hub("pyevent")
|
||||
""" This is the main module """
|
||||
from eventlet import hubs
|
||||
hubs.use_hub("pyevent")
|
||||
|
||||
Hubs are implemented as thread-local class instances. :func:`eventlet.hubs.use_hub` only operates on the current thread. When using multiple threads that each need their own hub, call :func:`eventlet.hubs.use_hub` at the beginning of each thread function that needs a specific hub. In practice, it may not be necessary to specify a hub in each thread; it works to use one special hub for the main thread, and let other threads use the default hub; this hybrid hub configuration will work fine.
|
||||
|
||||
It is also possible to use a third-party hub module in place of one of the built-in ones. Simply pass the module itself to :func:`eventlet.hubs.use_hub`. The task of writing such a hub is a little beyond the scope of this document, it's probably a good idea to simply inspect the code of the existing hubs to see how they work.
|
||||
|
||||
>>> from eventlet import hubs
|
||||
>>> hubs.use_hub(mypackage.myhubmodule)
|
||||
It is also possible to use a third-party hub module in place of one of the built-in ones. Simply pass the module itself to :func:`eventlet.hubs.use_hub`. The task of writing such a hub is a little beyond the scope of this document, it's probably a good idea to simply inspect the code of the existing hubs to see how they work.::
|
||||
|
||||
from eventlet import hubs
|
||||
from mypackage import myhub
|
||||
hubs.use_hub(myhub)
|
||||
|
||||
Supplying None as the argument to :func:`eventlet.hubs.use_hub` causes it to select the default hub.
|
Reference in New Issue
Block a user