fix(B2): _busy_started_at Reset-Logik korrigiert — keine künstliche Honeymoon-Verlängerung
This commit is contained in:
@@ -246,7 +246,11 @@ class PresenceEngine:
|
|||||||
with self._busy_honeymoon_lock:
|
with self._busy_honeymoon_lock:
|
||||||
self._busy_counter += 1
|
self._busy_counter += 1
|
||||||
if self._busy_honeymoon_timer is None:
|
if self._busy_honeymoon_timer is None:
|
||||||
# First busy start — record time and start honeymoon timer
|
# B2: _busy_started_at nur beim ERSTEN busy-Start setzen.
|
||||||
|
# Wenn der Honeymoon-Timer bereits abgelaufen ist (Timer=None)
|
||||||
|
# aber _busy_started_at noch existiert (weil active > 0),
|
||||||
|
# dann NICHT neu setzen — sonst künstliche Verlängerung um 1s.
|
||||||
|
if self._busy_started_at == 0.0:
|
||||||
self._busy_started_at = time.monotonic()
|
self._busy_started_at = time.monotonic()
|
||||||
self._busy_honeymoon_timer = threading.Timer(
|
self._busy_honeymoon_timer = threading.Timer(
|
||||||
self.MIN_BUSY_VISIBLE_S,
|
self.MIN_BUSY_VISIBLE_S,
|
||||||
@@ -255,8 +259,8 @@ class PresenceEngine:
|
|||||||
self._busy_honeymoon_timer.daemon = True
|
self._busy_honeymoon_timer.daemon = True
|
||||||
self._busy_honeymoon_timer.start()
|
self._busy_honeymoon_timer.start()
|
||||||
logger.debug(
|
logger.debug(
|
||||||
"[presence] Honeymoon-Timer gestartet (%.1fs), counter=%d",
|
"[presence] Honeymoon-Timer gestartet (%.1fs), counter=%d, started_at=%.3f",
|
||||||
self.MIN_BUSY_VISIBLE_S, self._busy_counter,
|
self.MIN_BUSY_VISIBLE_S, self._busy_counter, self._busy_started_at,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
logger.debug(
|
logger.debug(
|
||||||
@@ -308,6 +312,8 @@ class PresenceEngine:
|
|||||||
|
|
||||||
Called by threading.Timer after MIN_BUSY_VISIBLE_S.
|
Called by threading.Timer after MIN_BUSY_VISIBLE_S.
|
||||||
If no active tasks remain, sets status to online.
|
If no active tasks remain, sets status to online.
|
||||||
|
B3: Checks pending_status under _active_tasks_lock to prevent
|
||||||
|
race with mark_busy_started.
|
||||||
"""
|
"""
|
||||||
with self._busy_honeymoon_lock:
|
with self._busy_honeymoon_lock:
|
||||||
self._busy_honeymoon_timer = None
|
self._busy_honeymoon_timer = None
|
||||||
@@ -316,6 +322,9 @@ class PresenceEngine:
|
|||||||
active = self._active_tasks
|
active = self._active_tasks
|
||||||
|
|
||||||
if active == 0:
|
if active == 0:
|
||||||
|
# B2: Reset _busy_started_at when honeymoon fully expires
|
||||||
|
# and no active tasks remain — next busy cycle starts fresh.
|
||||||
|
self._busy_started_at = 0.0
|
||||||
logger.info(
|
logger.info(
|
||||||
"[presence] Honeymoon-Timer abgelaufen, active_tasks=0 → online"
|
"[presence] Honeymoon-Timer abgelaufen, active_tasks=0 → online"
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user