embutils.utils.service module

Service implementation.

date

2021

author

Christian Wiche

contact

cwichel@gmail.com

license

The MIT License (MIT)

class embutils.utils.service.AbstractService(delay: float = 0.001)[source]

Bases: abc.ABC

Service definition abstraction. Use this class to simplify the service definition and handling.

Class initialization.

Parameters

delay (float) – Time between service task executions.

TASK_DELAY_S = 0.001

Task execution delay.

_abc_impl = <_abc_data object>
_on_end() None[source]

Optional. Called upon service termination.

_on_pause() None[source]

Optional. Called on service pause.

_on_resume() None[source]

Optional. Called on service resume.

_on_start() None[source]

Optional. Called on service start.

_service() None[source]

Service process execution.

  1. Runs the starting code.

  2. Run the execution loop until the service stop is requested.

  3. Runs the ending code and return.

abstract _task() None[source]

Service core task/logic.

property delay: float

Service main task execution delay in seconds.

property is_alive: bool

Returns if the service is alive.

property is_running: bool

Returns if the service is running.

join() None[source]

Wait until service is fully terminated.

pause() None[source]

Pauses the service execution.

resume() None[source]

Resumes the service execution.

stop() None[source]

Stops the service execution.