Refactored timers module to use ctx.state and fixed new timers never firing.
CI / Formatting (push) Successful in 13s
CI / Linting (push) Successful in 14s
CI / Tests (Python 3.12) (push) Successful in 27s
CI / Tests (Python 3.13) (push) Successful in 26s
CI / Tests (Python 3.14) (push) Successful in 25s
CI / Type Checking (push) Successful in 24s
CI / Spelling (push) Successful in 14s
CI / Formatting (push) Successful in 13s
CI / Linting (push) Successful in 14s
CI / Tests (Python 3.12) (push) Successful in 27s
CI / Tests (Python 3.13) (push) Successful in 26s
CI / Tests (Python 3.14) (push) Successful in 25s
CI / Type Checking (push) Successful in 24s
CI / Spelling (push) Successful in 14s
This commit is contained in:
@@ -35,7 +35,7 @@ from .commands import (
|
||||
settimermessage,
|
||||
)
|
||||
from .routes import timer_list_page
|
||||
from .scheduler import TimerScheduler, clear_scheduler, get_scheduler, set_scheduler
|
||||
from .scheduler import TimerScheduler
|
||||
|
||||
__all__ = [
|
||||
"addtimer",
|
||||
@@ -91,7 +91,7 @@ async def setup(ctx: ModuleContext) -> None:
|
||||
ctx.logger.info(f"Loaded {count} timer(s) from database.")
|
||||
|
||||
sched.start(ctx)
|
||||
set_scheduler(sched)
|
||||
ctx.state["scheduler"] = sched
|
||||
|
||||
|
||||
@on_teardown
|
||||
@@ -102,5 +102,7 @@ async def teardown(ctx: ModuleContext) -> None:
|
||||
|
||||
:param ctx: Module context.
|
||||
"""
|
||||
await get_scheduler().stop(ctx)
|
||||
clear_scheduler()
|
||||
scheduler: TimerScheduler | None = ctx.state.get("scheduler")
|
||||
if scheduler is not None:
|
||||
await scheduler.stop(ctx)
|
||||
ctx.state["scheduler"] = None
|
||||
|
||||
Reference in New Issue
Block a user