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
master
justcool393 2022-11-17 10:34:30 -06:00
parent f4ad331d23
commit 8d46295d49
1 changed files with 9 additions and 10 deletions

View File

@ -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()
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")
except:
else:
worker.log.warning("No request info")
except:
worker.log.warning("Failed to get request info")
import os
os.abort()