scistag.remotestag.service_task.RemoteTask

class RemoteTask(task_id, service, target_function, parameters, timeout_s=-1.0)[source]

Bases: object

This function handles the execution of a remotely executed function

Parameters
  • task_id (int) – The task’s unique id

  • target_function (str) – The function to execute

  • parameters (dict) – The parameters to pass into the function

  • timeout_s (float) – The timeout in seconds after which this task automatically gets cancelled.

Methods

assign_error

Assigns an error to the result

assign_result

Assigns the result to the task

get_deprecation_time

Returns the time when this task becomes invalid

get_error

Returns the error string if an error occurred

get_id

Returns the task's unique ID

get_parameters

Returns the parameters passed into the function

get_result

Returns the task's result

get_service

Returns the service being required for this task

get_target_function

Returns the target function

unwrap

Unwraps the result dictionary to a single value if it just contains a single value

wait

Waits for the finishing of the execution up to a given timeout

Attributes

ERROR

__dict__

__doc__

__module__

__weakref__

list of weak references to the object (if defined)

_task_id

The task's unique id

_service

The service which provides the function

_target_function

The identifier of the function to call

_access_lock

Data access lock

_event

The even to be triggered to wake up sleeping receivers

_parameters

The function's parameters

_result

The function's result

_sleep_interval

Interval of sleep

timeout_s

The timeout time

assign_error(error)[source]

Assigns an error to the result

Parameters

error (str) – The error string

assign_result(result)[source]

Assigns the result to the task

Parameters

result – The task’s result

get_deprecation_time()[source]

Returns the time when this task becomes invalid

Return type

float

Returns

The deprecation time (see time.time()). If -1 the task does not deprecate.

get_error()[source]

Returns the error string if an error occurred

Return type

str | None

Returns

The error string

get_id()[source]

Returns the task’s unique ID

Return type

int

Returns

Unique task ID

get_parameters()[source]

Returns the parameters passed into the function

Returns

The parameters

get_result()[source]

Returns the task’s result

Return type

dict | None

Returns

The result data (if it’s available already)

get_service()[source]

Returns the service being required for this task

Return type

RemoteService

Returns

The service

get_target_function()[source]

Returns the target function

Return type

str

Returns

The function’s identifier

unwrap()[source]

Unwraps the result dictionary to a single value if it just contains a single value

Return type

RemoteReturnTypes | None

Returns

A dictionary in case of multiple return values otherwise the single value

wait(timeout_s=-1)[source]

Waits for the finishing of the execution up to a given timeout

Parameters

timeout_s – The maximum waiting time in seconds

Return type

bool

Returns

True if the data is available

_access_lock

Data access lock

_event

The even to be triggered to wake up sleeping receivers

_parameters: dict

The function’s parameters

_result: dict | None

The function’s result

_service

The service which provides the function

_sleep_interval

Interval of sleep

_target_function: str

The identifier of the function to call

_task_id

The task’s unique id

timeout_s

The timeout time