eventlet¶
Installation¶
To run Pykka on top of eventlet, you first need to install the eventlet package from PyPI:
pip install eventlet
Code changes¶
Next, all actors must subclass pykka.eventlet.EventletActor
instead of
pykka.ThreadingActor
.
If you create any futures yourself, you must replace
pykka.ThreadingFuture
with pykka.eventlet.EventletFuture
.
With those changes in place, Pykka should run on top of eventlet.
API¶
-
class
pykka.eventlet.
EventletEvent
[source]¶ EventletEvent
adaptseventlet.event.Event
tothreading.Event
interface.
-
class
pykka.eventlet.
EventletFuture
[source]¶ EventletFuture
implementspykka.Future
for use withEventletActor
.-
get
(timeout=None)[source]¶ Get the value encapsulated by the future.
If the encapsulated value is an exception, it is raised instead of returned.
If
timeout
isNone
, as default, the method will block until it gets a reply, potentially forever. Iftimeout
is an integer or float, the method will wait for a reply fortimeout
seconds, and then raisepykka.Timeout
.The encapsulated value can be retrieved multiple times. The future will only block the first time the value is accessed.
Parameters: timeout (float or None
) – seconds to wait before timeoutRaise: pykka.Timeout
if timeout is reachedRaise: encapsulated value if it is an exception Returns: encapsulated value if it is not an exception
-
set
(value=None)[source]¶ Set the encapsulated value.
Parameters: value (any picklable object or None
) – the encapsulated value or nothingRaise: an exception if set is called multiple times
-
set_exception
(exc_info=None)[source]¶ Set an exception as the encapsulated value.
You can pass an
exc_info
three-tuple, as returned bysys.exc_info()
. If you don’t passexc_info
,sys.exc_info()
will be called and the value returned by it used.In other words, if you’re calling
set_exception()
, without any arguments, from an except block, the exception you’re currently handling will automatically be set on the future.Parameters: exc_info (three-tuple of (exc_class, exc_instance, traceback)) – the encapsulated exception
-
-
class
pykka.eventlet.
EventletActor
(*args, **kwargs)[source]¶ EventletActor
implementspykka.Actor
using the eventlet library.This implementation uses eventlet green threads.