From 8d46295d49246e02971081f18ae24ed937af9bd0 Mon Sep 17 00:00:00 2001 From: justcool393 Date: Thu, 17 Nov 2022 10:34:30 -0600 Subject: [PATCH] workers: simplify error handler this prevents a relatively rare query to db still it makes me feel better, especially when we have only a little bit of time anyway --- gunicorn.conf.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/gunicorn.conf.py b/gunicorn.conf.py index 04038416a..f64fa8e73 100644 --- a/gunicorn.conf.py +++ b/gunicorn.conf.py @@ -8,23 +8,22 @@ max_requests_jitter = 30000 reload = True reload_engine = 'poll' -#print_config = True def worker_abort(worker): worker.log.warning(f"Worker {worker.pid} received SIGABRT.") try: - import flask - r = flask.request - worker.log.warning(f"While serving {r.method} {r.url}") - from files.routes.wrappers import get_logged_in_user - u = get_logged_in_user() - if u: - worker.log.warning(f"User: {u.username!r} id:{u.id}") + from flask import g, request + if g and request: + u = getattr(g, 'v', None) + if u: + worker.log.warning(f"User: {u.username!r} id:{u.id}") + else: + worker.log.warning(f"User: not logged in") else: - worker.log.warning(f"User: not logged in") + worker.log.warning("No request info") except: - worker.log.warning("No request info") + worker.log.warning("Failed to get request info") import os os.abort()