fix: prevent relay allocation starvation
This commit is contained in:
parent
46de16db00
commit
39f4e878b1
1 changed files with 5 additions and 1 deletions
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue