mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
Use a dynamic timeout to wait for the optimal time.
This commit is contained in:
parent
89a178ac3e
commit
d76bab4d71
@ -308,8 +308,15 @@ class Arbiter(object):
|
||||
Sleep until PIPE is readable or we timeout.
|
||||
A readable PIPE means a signal occurred.
|
||||
"""
|
||||
if self.WORKERS:
|
||||
oldest = min(w.tmp.last_update() for w in self.WORKERS.values())
|
||||
timeout = self.timeout - (time.time() - oldest)
|
||||
# The timeout can be reached, so don't wait for a negative value
|
||||
timeout = max(timeout, 1.0)
|
||||
else:
|
||||
timeout = 1.0
|
||||
try:
|
||||
ready = select.select([self.PIPE[0]], [], [], 1.0)
|
||||
ready = select.select([self.PIPE[0]], [], [], timeout)
|
||||
if not ready[0]:
|
||||
return
|
||||
while os.read(self.PIPE[0], 1):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user