diff --git a/CHANGES/7518.bugfix b/CHANGES/7518.bugfix new file mode 100644 index 00000000000..bc8083ba8ba --- /dev/null +++ b/CHANGES/7518.bugfix @@ -0,0 +1 @@ +Fix GunicornWebWorker max_requests_jitter not work diff --git a/aiohttp/worker.py b/aiohttp/worker.py index 975046e6a90..04822f33306 100644 --- a/aiohttp/worker.py +++ b/aiohttp/worker.py @@ -114,7 +114,7 @@ async def _run(self) -> None: self.notify() cnt = server.requests_count - if self.cfg.max_requests and cnt > self.cfg.max_requests: + if self.max_requests and cnt > self.max_requests: self.alive = False self.log.info("Max requests, shutting down: %s", self) diff --git a/tests/test_worker.py b/tests/test_worker.py index 2050e995245..c2ec4710636 100644 --- a/tests/test_worker.py +++ b/tests/test_worker.py @@ -217,8 +217,8 @@ async def test__run_ok_parent_changed( worker.sockets = [sock] worker.log = mock.Mock() worker.loop = loop + worker.max_requests = 0 worker.cfg.access_log_format = ACCEPTABLE_LOG_FORMAT - worker.cfg.max_requests = 0 worker.cfg.is_ssl = False await worker._run() @@ -240,8 +240,8 @@ async def test__run_exc( worker.sockets = [sock] worker.log = mock.Mock() worker.loop = loop + worker.max_requests = 0 worker.cfg.access_log_format = ACCEPTABLE_LOG_FORMAT - worker.cfg.max_requests = 0 worker.cfg.is_ssl = False def raiser() -> None: