Respect timeout when not accepting requests

So far the timeout was only in effect when any of the requests was
accepted by the launcher. When there are a lot of other requests (e.g.
to be declined) we might exceed the timout in some cases.

Change-Id: Iaed8302c94e12467834fadee25a80198db5e629d
This commit is contained in:
Simon Westphahl 2023-03-09 09:03:42 +01:00 committed by James E. Blair
parent 1ed2b855c8
commit 3209226fc1
1 changed files with 8 additions and 7 deletions

View File

@ -148,6 +148,14 @@ class PoolWorker(threading.Thread, stats.StatsReporter):
if not self.running:
return True
# if we exceeded the timeout stop iterating here
elapsed = time.monotonic() - start
if elapsed > timeout:
self.log.debug("Early exit from handler assignment on timeout "
"after %s/%s requests in %s",
req_count + 1, len(requests), elapsed)
return False
req = self.zk.getNodeRequest(req.id)
if not req:
continue
@ -279,13 +287,6 @@ class PoolWorker(threading.Thread, stats.StatsReporter):
self.paused_handlers.add(rh)
self.request_handlers.append(rh)
# if we exceeded the timeout stop iterating here
elapsed = time.monotonic() - start
if elapsed > timeout:
self.log.debug("Early exit from handler assignment on timeout "
"after %s/%s requests in %s",
req_count + 1, len(requests), elapsed)
return False
elapsed = time.monotonic() - start
self.log.debug("Finished handler assignment %s requests in %s",
len(requests), elapsed)