fix: prevent relay allocation starvation

This commit is contained in:
Alexander Sellite 2026-09-01 10:59:03 -04:00
parent 46de16db00
commit 39f4e878b1

View file

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