The default threading runtime has no dependencies other than Pykka itself and the Python standard library.
- class pykka.ThreadingFuture
Futurefor use with regular Python threads`.
The future is implemented using a
The future does not make a copy of the object which is
set()on it. It is the setters responsibility to only pass immutable objects or make a copy of the object before setting it on the future.
Changed in version 0.14: Previously, the encapsulated value was a copy made with
copy.deepcopy(), unless the encapsulated value was a future, in which case the original future was encapsulated.
- get(*, timeout: float | None = None) Any
Get the value encapsulated by the future.
If the encapsulated value is an exception, it is raised instead of returned.
None, as default, the method will block until it gets a reply, potentially forever. If
timeoutis an integer or float, the method will wait for a reply for
timeoutseconds, and then raise
The encapsulated value can be retrieved multiple times. The future will only block the first time the value is accessed.
timeout (float or
None) – seconds to wait before timeout
pykka.Timeoutif timeout is reached
encapsulated value if it is an exception
encapsulated value if it is not an exception
- set(value: Any | None = None) None
Set the encapsulated value.
value (any object or
None) – the encapsulated value or nothing
an exception if set is called multiple times
- set_exception(exc_info: OptExcInfo | None = None) None
Set an exception as the encapsulated value.
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.
exc_info (three-tuple of (exc_class, exc_instance, traceback)) – the encapsulated exception
- class pykka.ThreadingActor(*_args: Any, **_kwargs: Any)
Actorusing regular Python threads.
- use_daemon_thread: ClassVar[bool] = False
A boolean value indicating whether this actor is executed on a thread that is a daemon thread (
True) or not (
False). This must be set before
pykka.Actor.start()is called, otherwise
The entire Python program exits when no alive non-daemon threads are left. This means that an actor running on a daemon thread may be interrupted at any time, and there is no guarantee that cleanup will be done or that
pykka.Actor.on_stop()will be called.
Actors do not inherit the daemon flag from the actor that made it. It always has to be set explicitly for the actor to run on a daemonic thread.