WattsonServiceInterface#

class wattson.services.wattson_service_interface.WattsonServiceInterface#

Bases: ABC

Methods

call

callable_methods

get_pid

get_priority

Returns the service's priority

get_start_command

Returns the command to be executed for starting this service on the network node

is_killed

is_running

kill

Sends the SIGKILL to the process.

poll

Polls the service process.

restart

Restarts the service.

start

Start the service.

stop

Stop the service.

wait

Waits for the service process to terminate.

Attributes

id

name

abstractmethod get_pid() int | None#
Returns:

The PID of the service process or None if the service is not running.

Return type:

Optional[int]

abstractmethod get_priority() ServicePriority#

Returns the service’s priority

Returns:

The associated ServicePriority object

Return type:

ServicePriority

abstractmethod get_start_command() List[str]#

Returns the command to be executed for starting this service on the network node

Returns:

The start command as a list of strings.

Return type:

List[str]

abstractmethod is_killed() bool#
Returns:

Whether the service has been killed.

Return type:

bool

abstractmethod is_running() bool#
Returns:

Whether the service is currently running.

Return type:

bool

abstractmethod kill() bool#

Sends the SIGKILL to the process.

Returns:

True iff the service has been terminated.

Return type:

bool

abstractmethod poll() int | None#

Polls the service process.

Returns:

None or the return code of the process.

Return type:

Optional[int]

abstractmethod restart(refresh_config: bool = False) bool#

Restarts the service. Shortcut for (blocking) stop and start calls.

Parameters:

refresh_config (bool, optional) – Whether to refresh the config even if it already exists (Default value = False)

Returns:

Whether the service has been restarted successfully.

Return type:

bool

abstractmethod start(refresh_config: bool = False) bool#

Start the service.

Parameters:

refresh_config (bool, optional) – Whether to refresh the config even if it already exists. (Default value = False)

Returns:

True iff the service has been started.

Return type:

bool

abstractmethod stop(wait_seconds: float = 5, auto_kill: bool = False, async_callback: Callable[[WattsonServiceInterface], None] | None = None) bool#

Stop the service.

Parameters:
  • wait_seconds (float, optional) – Number of seconds to wait for the service to gracefully terminate. (Default value = 5)

  • auto_kill (bool, optional) – Whether to kill the service automatically after the waiting timeout has been exceeded. (Default value = False)

  • async_callback (Optional[Callable[['WattsonServiceInterface'], None]], optional) – An optional callback to call once the service has terminated. Makes the stop method return immediately. (Default value = None)

Returns:

None if an async_callback is given, else True iff the service has been terminated.

Return type:

bool

abstractmethod wait(timeout: float | None = None) int#

Waits for the service process to terminate. If a timeout is given and the process does not terminate during the timeout, a TimeoutExpired exception is thrown.

Parameters:

timeout (Optional[float], optional) – An optional timeout. (Default value = None)

Returns:

The processes return code.

Return type:

int