Added per-instance state dict to ModuleContext for multi-instance isolation.
CI / Formatting (push) Successful in 12s
CI / Linting (push) Successful in 11s
CI / Tests (Python 3.12) (push) Successful in 25s
CI / Tests (Python 3.13) (push) Successful in 25s
CI / Tests (Python 3.14) (push) Successful in 23s
CI / Type Checking (push) Successful in 22s
CI / Spelling (push) Successful in 11s
Dependency Audit / Dependency Audit (push) Successful in 17s
CI / Formatting (push) Successful in 12s
CI / Linting (push) Successful in 11s
CI / Tests (Python 3.12) (push) Successful in 25s
CI / Tests (Python 3.13) (push) Successful in 25s
CI / Tests (Python 3.14) (push) Successful in 23s
CI / Type Checking (push) Successful in 22s
CI / Spelling (push) Successful in 11s
Dependency Audit / Dependency Audit (push) Successful in 17s
This commit is contained in:
+1
-1
Submodule docs updated: 7882423a22...ec05d61acb
@@ -25,7 +25,7 @@ from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from dataclasses import dataclass, field
|
||||
from typing import TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from aiohttp import web
|
||||
@@ -77,6 +77,13 @@ class ModuleContext:
|
||||
# Optional admin client for the Owncast Admin API (None if admin is not enabled).
|
||||
admin_client: OwncastAdminClient | None = None
|
||||
|
||||
# Per-instance state storage for modules.
|
||||
# Modules can store runtime objects (managers, schedulers, etc.) here
|
||||
# instead of using module-level globals, ensuring multiple bot instances
|
||||
# in the same process don't share mutable state. Access values through
|
||||
# typed helper functions that narrow with isinstance checks.
|
||||
state: dict[str, Any] = field(default_factory=dict)
|
||||
|
||||
# Module-scoped logger (named "owlbot.modules.<module_name>").
|
||||
# Derived from module_name in __post_init__; not a constructor parameter.
|
||||
logger: logging.Logger = field(init=False)
|
||||
|
||||
Reference in New Issue
Block a user