diff --git a/plugins/python/uwsgi_python.h b/plugins/python/uwsgi_python.h index 9d2e34cc..8939372b 100644 --- a/plugins/python/uwsgi_python.h +++ b/plugins/python/uwsgi_python.h @@ -253,6 +253,8 @@ void uwsgi_python_reset_random_seed(void); char *uwsgi_pythonize(char *); +int uwsgi_python_manage_exceptions(void); + #ifdef UWSGI_PYPY #undef UWSGI_MINTERPRETERS #endif diff --git a/plugins/python/wsgi_subhandler.c b/plugins/python/wsgi_subhandler.c index 4f31df50..ffb74a6b 100644 --- a/plugins/python/wsgi_subhandler.c +++ b/plugins/python/wsgi_subhandler.c @@ -222,12 +222,16 @@ int uwsgi_response_subhandler_wsgi(struct wsgi_request *wsgi_req) { if (!pychunk) { if (PyErr_Occurred()) { + int do_exit = uwsgi_python_manage_exceptions(); if (PyErr_ExceptionMatches(PyExc_MemoryError)) { uwsgi_log("Memory Error detected !!!\n"); } uwsgi.workers[uwsgi.mywid].exceptions++; uwsgi_apps[wsgi_req->app_id].exceptions++; PyErr_Print(); + if (do_exit) { + exit(UWSGI_EXCEPTION_CODE); + } } if (PyObject_HasAttrString((PyObject *)wsgi_req->async_result, "close")) { PyObject *close_method = PyObject_GetAttrString((PyObject *)wsgi_req->async_result, "close");