Django: Catch/Log exceptions when using gevent-socketio and WSGIHandler
题
I'm extending upon the ideas presented in Cody Soyland's blog post on gevent-socketio here: http://codysoyland.com/2011/feb/6/evented-django-part-one-socketio-and-gevent/
But I am having trouble finding where exceptions are being swallowed up. Any errors that occur during the socketio loop seem to dissapear and execution will stop. I've tried using the python logging module as suggested in other threads regarding mod_wsgi but to no avail.
Can anyone help?
解决方案
This fixed it
import sys
import traceback
from django.core.signals import got_request_exception
def exception_printer(sender, **kwargs):
print >> sys.stderr, ''.join(traceback.format_exception(*sys.exc_info()))
got_request_exception.connect(exception_printer)
不隶属于 StackOverflow