PySeqActor

The class is specific implementation of Actor class using native Python Sequential functionality.

The PySeqActor implements 2 internal methods:

  • __getattr__() – transmits an access responsibility to the methods of class object, held by this class, to PySeqActorMethod class.

  • _remote() – creates an object of the required class to be held by this class.

API

class unidist.core.backends.pyseq.actor.PySeqActor(cls, num_cpus, resources)

The class implements the interface in Actor using Python Sequential backend.

Parameters:
  • cls (object) – Class to be an actor class.

  • num_cpus (int) – The number of CPUs to reserve for the lifetime of the actor.

  • resources (dict) – Custom resources to reserve for the lifetime of the actor.

_remote(*args, num_cpus=None, resources=None, **kwargs)

Create actor class, specific for Python Sequential backend, from self._cls.

Parameters:
  • *args (iterable) – Positional arguments to be passed in self._cls class constructor.

  • num_cpus (int, optional) – The number of CPUs to reserve for the lifetime of the actor.

  • resources (dict, optional) – Custom resources to reserve for the lifetime of the actor.

  • **kwargs (dict) – Keyword arguments to be passed in self._cls class constructor.

Return type:

PySeqActor

PySeqActorMethod

The class is specific implementation of ActorMethod class using native Python Sequential functionality.

The PySeqActorMethod implements internal method _remote() that is responsible for method calls of the wrapped class object using submit().

API

class unidist.core.backends.pyseq.actor.PySeqActorMethod(cls, method_name)

The class implements the interface in ActorMethod using Python Sequential backend.

Parameters:
  • cls (object) – An actor class from which method method_name will be called.

  • method_name (str) – The name of the method to be called.

_remote(*args, num_returns=None, **kwargs)

Execute self._method_name.

Parameters:
  • *args (iterable) – Positional arguments to be passed in the method.

  • num_returns (int, optional) – Number of results to be returned. If it isn’t provided, self._num_returns will be used.

  • **kwargs (dict) – Keyword arguments to be passed in the method.

Returns:

Type of returns depends on num_returns value:

  • if num_returns == 1, ObjectRef will be returned.

  • if num_returns > 1, list of ObjectRef-s will be returned.

  • if num_returns == 0, None will be returned.

Return type:

ObjectRef, list or None