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):