Skip to content

server_loop_service

messageflux.server_loop_service

LoopMetrics

LoopMetrics(loop_duration, exception=None)

a class that holds metrics for a single server loop

Parameters:

Name Type Description Default
loop_duration float

the duration (in seconds) that it took the loop to run

required
exception Optional[Exception]

the exception (if any) that the loop raised

None

exception property

exception

Returns:

Type Description

the exception (if any) that the loop raised

loop_duration property

loop_duration

Returns:

Type Description

the duration (in seconds) that it took the loop to run

ServerLoopService

ServerLoopService(
    *,
    duration_after_loop_success=0,
    duration_after_loop_failure=0,
    **kwargs
)

Bases: BaseService

this is a base class for services that uses a 'loop' as their running method

Parameters:

Name Type Description Default
duration_after_loop_success float

the duration (in seconds) to wait after successful run of the loop.

0
duration_after_loop_failure float

the duration (in seconds) to wait after failed run of the loop.

0
**kwargs

the init args for base classes

{}

loop_ended_event property

loop_ended_event

an event that is fired when a single server loop has ended