mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-09-08 14:41:55 +00:00
added uwsgi.after_req_hook
This commit is contained in:
@@ -1053,6 +1053,16 @@ void uwsgi_python_init_apps() {
|
||||
#endif
|
||||
}
|
||||
|
||||
PyObject *uwsgi_dict = get_uwsgi_pydict("uwsgi");
|
||||
if (uwsgi_dict) {
|
||||
up.after_req_hook = PyDict_GetItemString(uwsgi_dict, "after_req_hook");
|
||||
if (up.after_req_hook) {
|
||||
Py_INCREF(up.after_req_hook);
|
||||
up.after_req_hook_args = PyTuple_New(0);
|
||||
Py_INCREF(up.after_req_hook_args);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void uwsgi_python_master_fixup(int step) {
|
||||
|
||||
@@ -186,6 +186,9 @@ struct uwsgi_python {
|
||||
|
||||
int reload_os_env;
|
||||
|
||||
PyObject *after_req_hook;
|
||||
PyObject *after_req_hook_args;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -513,6 +513,17 @@ clear2:
|
||||
|
||||
void uwsgi_after_request_wsgi(struct wsgi_request *wsgi_req) {
|
||||
|
||||
if (up.after_req_hook) {
|
||||
PyObject *arh = python_call(up.after_req_hook, up.after_req_hook_args, 0, NULL);
|
||||
if (!arh) {
|
||||
PyErr_Print();
|
||||
}
|
||||
else {
|
||||
Py_DECREF(arh);
|
||||
}
|
||||
PyErr_Clear();
|
||||
}
|
||||
|
||||
if (uwsgi.shared->options[UWSGI_OPTION_LOGGING] || wsgi_req->log_this) {
|
||||
log_request(wsgi_req);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user