Skip to content

ctx_manager

Context manager definition for modern daemon handler

Classes:

  • DaemonHandler –

    Daemon handler class representing a context manager to be used in public API

DaemonHandler

DaemonHandler()

Daemon handler class representing a context manager to be used in public API

Multiple operations are supported: START, STOP, STATUS, RESTART.

When multiple START operations are requested under the same handler,
multiprocessing must be involved to make sure the first process daemonization is not blocking
and other daemons can be started after or at the same time without losing context.
RESTART (which also involves an underlying START op) is in the same situation.

STATUS and STOP can be executed from the same process.

Constructor func

Methods:

  • __enter__ –

    Context manager entry point

  • __exit__ –

    Context manager exit point

  • perform –

    Function to perform operations on currently-registered daemon requests.

  • restart –

    Function to add a request to restart input daemon

  • run –

    Function to run the daemon handler logic

  • start –

    Function to add a request to start input daemon

  • status –

    Function to add a request to get status from input daemon

  • stop –

    Function to add a request to stop input daemon

__enter__

__enter__() -> DaemonHandler

Context manager entry point

Returns:

  • DaemonHandler –

    Current object

__exit__

__exit__(exc_type, exc_val, exc_tb) -> None

Context manager exit point

Returns:

  • None –

    Nothing

perform

perform() -> None

Function to perform operations on currently-registered daemon requests.
This function handles START, STOP, RESTART and STATUS flags (defined in core.daemons.flags)

Returns:

  • None –

    Nothing

restart

restart(daemon: Daemon | None = None) -> DaemonHandler

Function to add a request to restart input daemon

Parameters:

  • daemon

    (Daemon | None, default: None ) –

    Daemon

Returns:

  • DaemonHandler –

    Self object

run

run() -> None

Function to run the daemon handler logic

Returns:

  • None –

    Nothing

start

start(daemon: Daemon | None = None) -> DaemonHandler

Function to add a request to start input daemon

Parameters:

  • daemon

    (Daemon | None, default: None ) –

    Daemon

Returns:

  • DaemonHandler –

    Self object

status

status(daemon: Daemon | None = None) -> DaemonHandler

Function to add a request to get status from input daemon

Parameters:

  • daemon

    (Daemon | None, default: None ) –

    Daemon

Returns:

  • DaemonHandler –

    Self object

stop

stop(daemon: Daemon | None = None) -> DaemonHandler

Function to add a request to stop input daemon

Parameters:

  • daemon

    (Daemon | None, default: None ) –

    Daemon

Returns:

  • DaemonHandler –

    Self object