Skip to content

task_monitor

Task monitoring and cleanup utilities for the Tux bot.

Encapsulates background task monitoring and shutdown cleanup routines.

Classes:

  • TaskMonitor

    Manage monitoring and cleanup of asyncio tasks for a bot instance.

Classes

TaskMonitor

Python
TaskMonitor(bot: Any)

Manage monitoring and cleanup of asyncio tasks for a bot instance.

Initialize the task monitor.

Parameters:

  • bot (Any) –

    The bot instance to monitor tasks for.

Methods:

  • start

    Start the background task monitoring loop.

  • stop

    Stop the background task monitoring loop if running.

  • cleanup_tasks

    Clean up all running tasks across the bot and cogs.

Functions

start
Python
start() -> None

Start the background task monitoring loop.

stop
Python
stop() -> None

Stop the background task monitoring loop if running.

_monitor_tasks_loop_impl async
Python
_monitor_tasks_loop_impl() -> None

Monitor and clean up running tasks periodically.

Raises:

  • RuntimeError

    If task monitoring encounters a critical failure.

_categorize_tasks
Python
_categorize_tasks(tasks_list: list[Task[Any]]) -> dict[str, list[Task[Any]]]

Categorize tasks by type for monitoring and cleanup.

Returns:

_process_finished_tasks async
Python
_process_finished_tasks(tasks_by_type: dict[str, list[Task[Any]]]) -> None

Process and clean up finished tasks.

cleanup_tasks async
Python
cleanup_tasks() -> None

Clean up all running tasks across the bot and cogs.

_stop_task_loops async
Python
_stop_task_loops() -> None

Stop all task loops in cogs as well as the monitor loop itself.

_cancel_tasks async
Python
_cancel_tasks(tasks_by_type: dict[str, list[Task[Any]]]) -> None

Cancel tasks by category and await their completion.

Functions