Possible causes of WORKER TIMEOUT #3065
Replies: 2 comments 4 replies
-
|
Hello 👋! After doing quite some research, we today deployed the following configuration on our servers: Additional notes:
I’ll keep you posted about the success of this new configuration. |
Beta Was this translation helpful? Give feedback.
-
|
Hi, EDIT (Oct 21, 2025): def spawn_worker(self):
self.worker_age += 1
worker = self.worker_class(self.worker_age, self.pid, self.LISTENERS,
self.app, self.timeout / 2.0,
self.cfg, self.log)
self.cfg.pre_fork(self, worker)
pid = os.fork()
if pid != 0:
worker.pid = pid
self.WORKERS[pid] = worker
return pid
# Do not inherit the temporary files of other workers
for sibling in self.WORKERS.values():
sibling.tmp.close()
# Process Child
worker.pid = os.getpid()
exitcode=os.EX_OK
try:
util._setproctitle("worker [%s]" % self.proc_name)
self.log.info("Booting worker with pid: %s", worker.pid)
if self.cfg.reuse_port:
worker.sockets = sock.create_sockets(self.cfg, self.log)
self.cfg.post_fork(self, worker)
worker.init_process()
sys.exit(0)
except SystemExit:
raise
except AppImportError as e:
self.log.debug("Exception while loading the application",
exc_info=True)
print("%s" % e, file=sys.stderr)
sys.stderr.flush()
exitcode = self.APP_LOAD_ERROR
sys.exit(self.APP_LOAD_ERROR)
except Exception:
self.log.exception("Exception in worker process")
if not worker.booted:
exitcode = self.WORKER_BOOT_ERROR
sys.exit(self.WORKER_BOOT_ERROR)
exitcode = -1
sys.exit(-1)
finally:
self.log.info("Worker exiting (pid: %s)", worker.pid)
try:
worker.tmp.close()
self.cfg.worker_exit(self, worker)
except Exception:
self.log.warning("Exception during worker exit:\n%s",
traceback.format_exc())
finally:
os._exit(exitcode)sys.exit() only exits the thread of the child process, but not the child process itself. @pajod, what do you think? Am I missing something? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello Gunicorn community! 👋
Today WORKER TIMEOUTs happened on our server. There was pretty high load due to many webhook events being processed and after a while Gunicorn workers started to fail with WORKER TIMEOUT (see log below).
Our Gunicorn configuration:
gunicorn --workers 5 --worker-connections=1000 --worker-class=gevent --bind localhost:8000 --disable-redirect-access-to-syslogQuestions:
timeoutbe set explicitly when using gevent, e.g.--timeout 600?max-requestsas recommended by Adam? https://adamj.eu/tech/2019/09/19/working-around-memory-leaks-in-your-django-app/Last update to psycogreen was in 2022.
Grateful for any hints and recommendations! 🙇
/var/log/syslog:
Beta Was this translation helpful? Give feedback.
All reactions