scistag.remotestag.service_handler.RemoteServiceHandler

class RemoteServiceHandler[source]

Bases: object

Orchestrates the single services and their associated execution resources

Methods

execute_async

Initiates the asynchronous execution of a function :type identifier: str :param identifier: The function's identifier :type parameters: Union[dict, str, float, bool, int, bytes] :param parameters: The function parameters :type timeout_s: float :param timeout_s: The timeout in seconds.

flag_as_done

Flags a task as done :type task: RemoteTask :param task: The task to flag as done

get_default_handler

Returns the default remote handler

get_in_progress

Returns the count of tasks which are in progress :rtype: int :return: The count of tasks in progress

get_task

Tries to find a suitable task for the list of supported services.

get_todo

Returns the count of tasks waiting on the to do list :rtype: int :return: The count of tasks which did not start yet

register_service

Registers a new service :type service: RemoteService :param service: The new service

start

Initiates the handler :rtype: bool :return: True on success

stop

Stops the handler :rtype: bool :return: True on success

Attributes

__annotations__

__dict__

__doc__

__module__

__weakref__

list of weak references to the object (if defined)

default_handler

The singleton default handler

_call_counter

Call id counter

_todo

Tasks to be executed

_in_progress

Tasks in progress

__start_workers()

Winds up all worker threads

__stop_workers()

Stop and join all workers

execute_async(identifier, parameters, timeout_s=-1.0)[source]

Initiates the asynchronous execution of a function :type identifier: str :param identifier: The function’s identifier :type parameters: Union[dict, str, float, bool, int, bytes] :param parameters: The function parameters :type timeout_s: float :param timeout_s: The timeout in seconds. Very recommended in case you access this service from the web. :rtype: RemoteTask :return: The task to retrieve the result with

flag_as_done(task)[source]

Flags a task as done :type task: RemoteTask :param task: The task to flag as done

classmethod get_default_handler()[source]

Returns the default remote handler

get_in_progress()[source]

Returns the count of tasks which are in progress :rtype: int :return: The count of tasks in progress

get_task(identifier_set)[source]

Tries to find a suitable task for the list of supported services. Moves the task internal from to do to in progress :param identifier_set: The supported services :rtype: RemoteTask | None :return: A new task if one is available.

get_todo()[source]

Returns the count of tasks waiting on the to do list :rtype: int :return: The count of tasks which did not start yet

register_service(service)[source]

Registers a new service :type service: RemoteService :param service: The new service

Return type

bool

start()[source]

Initiates the handler :rtype: bool :return: True on success

stop()[source]

Stops the handler :rtype: bool :return: True on success

_call_counter

Call id counter

_in_progress

Tasks in progress

_todo

Tasks to be executed

default_handler: RemoteServiceHandler = <scistag.remotestag.service_handler.RemoteServiceHandler object>

The singleton default handler