Make force close on max requests consistent

All worker types should force a connection close after a request that
exceeds the max requests. A worker only needs to log about the automatic
restart once, rather than once for each keepalive request.
This commit is contained in:
Randall Leeds 2020-04-20 13:13:34 -07:00
parent 4591b51db8
commit ebb41da472
2 changed files with 7 additions and 5 deletions

View File

@ -95,10 +95,11 @@ class AsyncWorker(base.Worker):
listener_name, self.cfg)
environ["wsgi.multithread"] = True
self.nr += 1
if self.alive and self.nr >= self.max_requests:
self.log.info("Autorestarting worker after current request.")
if self.nr >= self.max_requests:
if self.alive:
self.log.info("Autorestarting worker after current request.")
self.alive = False
resp.force_close()
self.alive = False
if not self.cfg.keepalive:
resp.force_close()

View File

@ -308,9 +308,10 @@ class ThreadWorker(base.Worker):
environ["wsgi.multithread"] = True
self.nr += 1
if self.nr >= self.max_requests:
self.log.info("Autorestarting worker after current request.")
if self.alive:
self.log.info("Autorestarting worker after current request.")
self.alive = False
resp.force_close()
self.alive = False
if not self.cfg.keepalive:
resp.force_close()