fix: pace inter-tier polling; fix stale package-rename references in docs
This commit is contained in:
1 parent
3a2d3da3b2
commit
27480dcb1d
3 files changed
+11
-9
No files matched your search
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
"""Stdout logging — works correctly under Docker's PYTHONUNBUFFERED=1.
|
"""Stdout logging — works correctly under Docker's PYTHONUNBUFFERED=1.
|
||||||
|
|
||||||
Two logger families share the root handler:
|
Two logger families share the root handler:
|
||||||
* `samsung_appliance` (and its children) for module-level lines —
|
* `mqtt_demo` (and its children) for module-level lines —
|
||||||
DTLS warnings, generic startup chatter, MQTT plumbing.
|
DTLS warnings, generic startup chatter, MQTT plumbing.
|
||||||
* `<class>.<serial>` for per-appliance bridge lines — e.g.
|
* `<class>.<serial>` for per-appliance bridge lines — e.g.
|
||||||
`dryer.<serial>`. Each PushBridge gets its own such logger
|
`dryer.<serial>`. Each PushBridge gets its own such logger
|
||||||
@@ -58,7 +58,7 @@ _handler.setFormatter(_LevelColourFormatter(
|
|||||||
|
|
||||||
logging.basicConfig(level=logging.INFO, handlers=[_handler], force=True)
|
logging.basicConfig(level=logging.INFO, handlers=[_handler], force=True)
|
||||||
|
|
||||||
logger = logging.getLogger("samsung_appliance")
|
logger = logging.getLogger("mqtt_demo")
|
||||||
|
|
||||||
|
|
||||||
def bridge_logger(klass: str, serial: str | None = None) -> logging.Logger:
|
def bridge_logger(klass: str, serial: str | None = None) -> logging.Logger:
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
"""Appliance descriptors registry.
|
"""Appliance descriptors registry.
|
||||||
|
|
||||||
Adding a new appliance class:
|
Adding a new appliance class:
|
||||||
1. Write `appliances/<class>.py` with an ApplianceDescriptor named
|
1. Write `mqtt_demo/samples/<class>.py` with an ApplianceDescriptor
|
||||||
after the class (uppercase, e.g. OVEN).
|
named after the class (uppercase, e.g. OVEN).
|
||||||
2. Add it to DESCRIPTORS below.
|
2. Add it to DESCRIPTORS below.
|
||||||
3. Set DEVICE_CLASS=<class> in the per-device .env.
|
3. Set DEVICE_CLASS=<class> in the per-device .env.
|
||||||
|
|
||||||
main.py imports get_descriptor(name) to look up the descriptor at
|
mqtt_demo/__main__.py imports get_descriptor(name) to look up the
|
||||||
startup; the bridge itself stays class-agnostic.
|
descriptor at startup; the bridge itself stays class-agnostic.
|
||||||
"""
|
"""
|
||||||
from ..descriptor import ApplianceDescriptor
|
from ..descriptor import ApplianceDescriptor
|
||||||
from .dryer import DRYER
|
from .dryer import DRYER
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
Tiers are descriptor-declared (hot/warm/cold + sweep). Per tick:
|
Tiers are descriptor-declared (hot/warm/cold + sweep). Per tick:
|
||||||
each tier whose deadline has passed polls all its paths sequentially
|
each tier whose deadline has passed polls all its paths sequentially
|
||||||
on the shared session, writing into the StateCache. The sweep tier
|
on the shared session, writing into the StateCache. The sweep tier
|
||||||
issues one Block2 GET of /device/0 and uses index_links to fan its
|
issues one Block2 GET of /device/0 and uses
|
||||||
result into many href reps.
|
StateCache.index_device_tree to fan its result into many href reps.
|
||||||
|
|
||||||
Adaptive cadence: when descriptor.is_active(cache.links) returns True
|
Adaptive cadence: when descriptor.is_active(cache.links) returns True
|
||||||
and tier.active_interval_s is set, that tier uses the tighter cadence.
|
and tier.active_interval_s is set, that tier uses the tighter cadence.
|
||||||
@@ -218,11 +218,13 @@ class PollScheduler:
|
|||||||
def _do_tier(self, tier: PollTier) -> None:
|
def _do_tier(self, tier: PollTier) -> None:
|
||||||
timeout = self._tier_timeout(tier)
|
timeout = self._tier_timeout(tier)
|
||||||
cooldown = self._cooldown_for(tier)
|
cooldown = self._cooldown_for(tier)
|
||||||
for path in tier.paths:
|
for i, path in enumerate(tier.paths):
|
||||||
href = '/' + '/'.join(path)
|
href = '/' + '/'.join(path)
|
||||||
with self._defer_lock:
|
with self._defer_lock:
|
||||||
if self._defer_until.get(href, 0) > time.monotonic():
|
if self._defer_until.get(href, 0) > time.monotonic():
|
||||||
continue
|
continue
|
||||||
|
if i > 0:
|
||||||
|
self.session.pace()
|
||||||
self._poll_count += 1
|
self._poll_count += 1
|
||||||
t0 = time.monotonic()
|
t0 = time.monotonic()
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in new issue
Block a user