fixed exception management in python mules and improved uwsgidecorators

This commit is contained in:
Unbit
2013-02-19 07:11:45 +01:00
parent 5089123e5a
commit 12bf2cd3af
4 changed files with 22 additions and 5 deletions
+2 -1
View File
@@ -245,7 +245,7 @@ void uwsgi_manage_exception(struct wsgi_request *wsgi_req,int catch) {
goto check_catch;
}
if (!wsgi_req) goto log;
if (!wsgi_req) goto log2;
uwsgi.workers[uwsgi.mywid].cores[wsgi_req->async_id].exceptions++;
uwsgi_apps[wsgi_req->app_id].exceptions++;
@@ -311,6 +311,7 @@ log:
uwsgi.p[wsgi_req->uh->modifier1]->exception_log(wsgi_req);
}
log2:
if (do_exit) {
exit(UWSGI_EXCEPTION_CODE);
}
+1 -1
View File
@@ -81,7 +81,7 @@ void uwsgi_mule(int id) {
for (i = 0; i < 256; i++) {
if (uwsgi.p[i]->mule) {
if (uwsgi.p[i]->mule(uwsgi.mules[id - 1].patch) == 1) {
// never here
// never here ?
end_me(1);
}
}
+6 -1
View File
@@ -208,7 +208,12 @@ PyObject *python_call(PyObject *callable, PyObject *args, int catch, struct wsgi
//uwsgi_log("called\n");
if (PyErr_Occurred()) {
uwsgi_manage_exception(wsgi_req, catch);
if (wsgi_req) {
uwsgi_manage_exception(wsgi_req, catch);
}
else {
PyErr_Print();
}
}
#ifdef UWSGI_DEBUG
+13 -2
View File
@@ -1,4 +1,5 @@
import uwsgi
import sys
from threading import Thread
try:
@@ -170,7 +171,12 @@ class mule_brain(object):
def __call__(self):
if uwsgi.mule_id() == self.num:
self.f()
try:
self.f()
except:
exc = sys.exc_info()
sys.excepthook(exc[0], exc[1], exc[2])
sys.exit(1)
class mule_brainloop(mule_brain):
@@ -178,7 +184,12 @@ class mule_brainloop(mule_brain):
def __call__(self):
if uwsgi.mule_id() == self.num:
while True:
self.f()
try:
self.f()
except:
exc = sys.exc_info()
sys.excepthook(exc[0], exc[1], exc[2])
sys.exit(1)
class mule(object):