From 73ae03823f48829b187a59d2e2f370b89c4e574b Mon Sep 17 00:00:00 2001 From: bingyun <578210452@qq.com> Date: Fri, 3 Jan 2025 15:01:15 +0800 Subject: [PATCH] fix: the worker_abort hook interrupted after executing part --- gunicorn/arbiter.py | 2 +- gunicorn/workers/base.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/gunicorn/arbiter.py b/gunicorn/arbiter.py index 646d684ef..686764e83 100644 --- a/gunicorn/arbiter.py +++ b/gunicorn/arbiter.py @@ -503,8 +503,8 @@ def murder_workers(self): if not worker.aborted: self.log.critical("WORKER TIMEOUT (pid:%s)", pid) - worker.aborted = True self.kill_worker(pid, signal.SIGABRT) + worker.aborted = True else: self.kill_worker(pid, signal.SIGKILL) diff --git a/gunicorn/workers/base.py b/gunicorn/workers/base.py index 93c465c98..1cef731c1 100644 --- a/gunicorn/workers/base.py +++ b/gunicorn/workers/base.py @@ -199,8 +199,9 @@ def handle_quit(self, sig, frame): sys.exit(0) def handle_abort(self, sig, frame): - self.alive = False self.cfg.worker_abort(self) + self.alive = False + time.sleep(0.1) sys.exit(1) def handle_error(self, req, client, addr, exc):