Skip to content

Scheduler

Scheduler

The main Scheduler class for the Python side of MMMAudio. Can be used to run asyncio coroutines in a separate scheduling thread. This has the advantage of not blocking the main thread, but also allows for each schedule to be cancelled individually.

__init__()

Initialize the Scheduler. Also starts the asyncio event loop in its own unique thread.

get_routs()

Get all running routine.

sched(coro)

Add a coroutine to the running event loop.

Parameters:

Name Type Description Default
coro

The coroutine to be scheduled.

required

Returns:

Type Description

The Future object representing the scheduled coroutine. This returned object can be used to check the status of the coroutine, retrieve its result, or stop the coroutine when needed.

start_thread()

Create a new asyncio event loop and run it in a separate scheduling thread.

stop_routs()

Stop all running routines.

stop_thread()

Stop the asyncio event loop and thread and start a new one.

tc_sleep(delay, result=None) async

Coroutine that completes after a given time (in seconds).

Parameters:

Name Type Description Default
delay

Time in seconds to wait before completing the coroutine.

required
result

Optional result to return when the coroutine completes.

None