python - Django AdminEmailHandler causing wsgi to hang -
python - Django AdminEmailHandler causing wsgi to hang -
i'm building webapp using django 1.7 on python 2.7, deployed in production apache , mod_wsgi in daemon mode. i'm having problem wsgi hangs whenever have exception logged (with python logging) , adminemailhandler configured in settings.py.
when request page browser hangs until apache log shows "end of script output before headers: wsgi.py"
i have 2 logging handlers configured, filehandler , adminemailhandler, , when comment out adminemailhandler problem doesn't occur.
'handlers': { 'file': { 'level': 'info', 'class': 'logging.filehandler', 'filename': '/var/log/apache2/mylog', 'formatter':'simple', }, 'email': { 'level': 'error', 'class': 'django.utils.log.adminemailhandler', 'formatter':'simple', }
i have seen configure wsgi with
wsgiapplicationgroup %{global}
and there application issues mod_wsgi (from this question).
however maintain daemon mode if possible, , adminemailhandler seems core piece of logging functionality i'm surprised hasn't been encountered before!
thanks in advance help
updatei fixed issue own subclass of adminemailhandler delegates email sending separate thread. vinay help!
from threading import thread import django.utils.log djangolog class myadminemailhandler(djangolog.adminemailhandler): def emit(self, record): try: thread = thread(target=djangolog.adminemailhandler.emit, args=(self, record)) thread.start() except: self.handleerror(record)
i don't believe related daemon mode - it's more smtp blocking web app. see this question , answers possible solution.
python django apache logging wsgi
Comments
Post a Comment