From 39f4e878b12b65193fd735d9fc0dfb9ad88496ec Mon Sep 17 00:00:00 2001 From: Voyager Date: Tue, 1 Sep 2026 10:59:03 -0400 Subject: [PATCH] fix: prevent relay allocation starvation --- straywild_discovery/relay.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/straywild_discovery/relay.py b/straywild_discovery/relay.py index 9ab96f1..944c8e0 100644 --- a/straywild_discovery/relay.py +++ b/straywild_discovery/relay.py @@ -211,8 +211,12 @@ class RelayService: def _run(self) -> None: while not self._stop.is_set(): + # Waiting for network activity must not hold the allocation lock. + # Otherwise the worker can immediately reacquire the lock on each + # timeout and starve HTTP handlers trying to create a relay route, + # especially on small single-core hosts. + events = self._selector.select(timeout=0.05) with self._lock: - events = self._selector.select(timeout=0.05) for key, _mask in events: allocation = key.data if isinstance(allocation, _Allocation):