common.runners.runnable
Runnable Objects
class Runnable(ABC, Generic[TExecutor])
__new__
def __new__(cls: Type["Runnable[TExecutor]"], *args: Any,
**kwargs: Any) -> "Runnable[TExecutor]"
Registers Runnable instance as running for a time when context is active.
Used with ~workermethod
decorator to pass a class instance to decorator function that must be static thus avoiding pickling such instance.
Arguments:
cls
Type["Runnable"] - type of class to be instantiated
Returns:
Runnable
- new class instance
workermethod
def workermethod(f: TFun) -> TFun
Decorator to be used on static method of Runnable to make it behave like instance method.
Expects that first parameter to decorated function is an instance id
of Runnable that gets translated into Runnable instance.
Such instance is then passed as self
to decorated function.
Arguments:
f
TFun - worker function to be decorated
Returns:
TFun
- wrapped worker function