WattsonServiceInterface#

class wattson.services.wattson_service_interface.WattsonServiceInterface#

Bases: ABC

Methods

call

callable_methods

get_pid

returns:

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

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

returns:

Whether the service has been killed.

is_running

returns:

Whether the service is currently 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

abstract get_pid() int | None#
Returns:

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

Return type:

Optional[int]

abstract get_priority() ServicePriority#

Returns the service’s priority

Returns:

The associated ServicePriority object

Return type:

ServicePriority

abstract 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]

abstract is_killed() bool#
Returns:

Whether the service has been killed.

Return type:

bool

abstract is_running() bool#
Returns:

Whether the service is currently running.

Return type:

bool

abstract kill() bool#

Sends the SIGKILL to the process.

Returns:

True iff the service has been terminated.

Return type:

bool

abstract poll() int | None#

Polls the service process.

Returns:

None or the return code of the process.

Return type:

Optional[int]

abstract 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

abstract 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

abstract 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

abstract 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