call gevent atexit hook before destroying uwsgi-related greenlets

This commit is contained in:
Unbit
2013-04-25 07:09:39 +02:00
parent 409710b2b1
commit 86e651f5e7
2 changed files with 12 additions and 9 deletions
+2
View File
@@ -588,6 +588,8 @@ void uwsgi_close_request(struct wsgi_request *wsgi_req) {
}
}
else {
// could have been changed in the mean time
ub = wsgi_req->response_buffer;
wsgi_req->write_errors++;
}
uwsgi_buffer_destroy(ub);
+10 -9
View File
@@ -29,6 +29,16 @@ PyObject *py_uwsgi_gevent_graceful(PyObject *self, PyObject *args) {
uwsgi_log("Gracefully killing worker %d (pid: %d)...\n", uwsgi.mywid, uwsgi.mypid);
uwsgi.workers[uwsgi.mywid].manage_next_request = 0;
// no need to worry about freeing memory
PyObject *uwsgi_dict = get_uwsgi_pydict("uwsgi");
if (uwsgi_dict) {
PyObject *ae = PyDict_GetItemString(uwsgi_dict, "atexit");
if (ae) {
python_call(ae, PyTuple_New(0), 0, NULL);
}
}
uwsgi_log_verbose("stopping gevent signals watchers for worker %d (pid: %d)...\n", uwsgi.mywid, uwsgi.mypid);
PyObject_CallMethod(ugevent.my_signal_watcher, "stop", NULL);
@@ -430,15 +440,6 @@ static void gevent_loop() {
}
if (uwsgi.workers[uwsgi.mywid].manage_next_request == 0) {
// no need to worry about freeing memory
PyObject *uwsgi_dict = get_uwsgi_pydict("uwsgi");
if (uwsgi_dict) {
PyObject *ae = PyDict_GetItemString(uwsgi_dict, "atexit");
if (ae) {
python_call(ae, PyTuple_New(0), 0, NULL);
}
}
uwsgi_log("goodbye to the gevent Hub on worker %d (pid: %d)\n", uwsgi.mywid, uwsgi.mypid);
if (ugevent.destroy) {
exit(0);