Skip to content

Commit 8bd42e7

Browse files
authored
Fix GunicornWebWorker max_requests_jitter not work (#7518)
`GunicornWebWorker` use `self.cfg.max_requests` which is not add jitter, from https://github.com/benoitc/gunicorn/blob/master/gunicorn/workers/base.py#L56-L60, the correct way is to use `sef.max_requests`
1 parent e481c05 commit 8bd42e7

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

CHANGES/7518.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix GunicornWebWorker max_requests_jitter not work

aiohttp/worker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ async def _run(self) -> None:
110110
self.notify()
111111

112112
cnt = server.requests_count
113-
if self.cfg.max_requests and cnt > self.cfg.max_requests:
113+
if self.max_requests and cnt > self.max_requests:
114114
self.alive = False
115115
self.log.info("Max requests, shutting down: %s", self)
116116

tests/test_worker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,8 @@ async def test__run_ok_parent_changed(
214214
worker.sockets = [sock]
215215
worker.log = mock.Mock()
216216
worker.loop = loop
217+
worker.max_requests = 0
217218
worker.cfg.access_log_format = ACCEPTABLE_LOG_FORMAT
218-
worker.cfg.max_requests = 0
219219
worker.cfg.is_ssl = False
220220

221221
await worker._run()
@@ -237,8 +237,8 @@ async def test__run_exc(
237237
worker.sockets = [sock]
238238
worker.log = mock.Mock()
239239
worker.loop = loop
240+
worker.max_requests = 0
240241
worker.cfg.access_log_format = ACCEPTABLE_LOG_FORMAT
241-
worker.cfg.max_requests = 0
242242
worker.cfg.is_ssl = False
243243

244244
def raiser() -> None:

0 commit comments

Comments
 (0)