Event Producers

detroit_live.event_producers() EventProducers

Returns a new instance of event producers.

Returns:

Event Producers

Return type:

EventProducers

class detroit_live.events.event_producers.EventProducers
add_timer(callback: Callable[[float, TimerEvent], None], updated_nodes: list[Element] | None = None, html_nodes: list[Element] | None = None, delay: float | None = None, starting_time: float | None = None) TimerModifier

Adds a timer which will calls callback until its timer event is set.

Parameters:
  • callback (Callable[[float, TimerEvent], None]) – Timer callback

  • updated_nodes (list[etree.Element] | None) – Nodes to update when the timer callback is called

  • html_nodes (list[etree.Element] | None) – Same as updated_nodes but update the innerHTML as well

  • delay (float | None) – Delay value

  • starting_time (float | None) – Starting time value

Returns:

Timer modifier

Return type:

TimerModifier

add_interval(callback: Callable[[float, TimerEvent], None], updated_nodes: list[Element] | None = None, html_nodes: list[Element] | None = None, delay: float | None = None, starting_time: float | None = None) TimerModifier

Adds a interval timer which will calls callback until its timer event is set.

Parameters:
  • callback (Callable[[float, TimerEvent], None]) – Timer callback

  • updated_nodes (list[etree.Element] | None) – Nodes to update when the timer callback is called

  • html_nodes (list[etree.Element] | None) – Same as updated_nodes but update the innerHTML as well

  • delay (float | None) – Delay value

  • starting_time (float | None) – Starting time value

Returns:

Timer modifier

Return type:

TimerModifier

remove_timer(timer_modifier: TimerModifier)

Removes a non started timer.

Parameters:

timer_modifier (TimerModifier) – Timer Modifier

next_tasks(timer_id: int | None = None) set[Task] | None

Returns the next tasks to await if some new tasks have to be (re)started. Removes the timer_id of pending tasks if the specified value is valid.

Parameters:

result (int | None) – Last result

Returns:

Next tasks to await

Return type:

set[asyncio.Task] | None

queue_task(result: Any | None = None) Task | None

Returns a queue task (asyncio.create_task(queue.get())) depending the last result.

Parameters:

result (Any | None) – Last result

Returns:

Asynchrous queue.get task

Return type:

asyncio.Task | None

class detroit_live.events.event_producers.TimerModifier(timer: Timer, updated_nodes: list[Element] | None, html_nodes: list[Element] | None, future_tasks: Queue[tuple[TimerStatus, TimerParameters | int]] | None)

Class which holds a Timer and supplies restart and stop methods applied on the timer object. Also future tasks and stopped tasks information are shared to EventProducers when calling these methods.

Parameters:
  • updated_nodes (list[etree.Element] | None) – Nodes to update when the timer callback is called

  • html_nodes (list[etree.Element] | None) – Same as updated_nodes but update the innerHTML as well

  • future_tasks (Queue[tuple[TimerStatus, TimerParameters | int]] | None) – Queue to share future tasks and stopped tasks to EventProducers

restart(callback: Callable[[float, TimerEvent], None], delay: float | None = None, starting_time: float | None = None)

Restarts the timer.

Parameters:
  • callback (Callable[[float, TimerEvent], None]) – Timer callback

  • delay (float | None) – Delay value

  • starting_time (float | None) – Starting time value

stop()

Stops the timer.

class detroit_live.events.event_producers.TimerParameters(timer: Timer, callback: Callable[[float, TimerEvent], None], updated_nodes: list[Element] | None, html_nodes: list[Element] | None, delay: float | None, starting_time: float | None)

Data class which holds all parameters to make a Timer

timer

Initialized empty timer instance

Type:

Timer

callback

Timer callback

Type:

Callable[[float, TimerEvent], None]

updated_nodes

Nodes to update when the timer callback is called

Type:

list[etree.Element] | None

html_nodes

Same as updated_nodes but update the innerHTML as well

Type:

list[etree.Element] | None

delay

Delay value

Type:

float | None

starting_time

Starting time value

Type:

float | None