goodbye_cruel_world hook for gevent

This commit is contained in:
roberto@quantal64
2012-06-19 08:00:32 +02:00
parent 1367ee1e40
commit 33c9d01baf
3 changed files with 23 additions and 2 deletions
+10
View File
@@ -49,6 +49,13 @@ PyObject *py_uwsgi_gevent_graceful(PyObject *self, PyObject *args) {
return Py_None;
}
void uwsgi_gevent_gbcw() {
uwsgi_log("...The work of process %d is done. Seeya!\n", getpid());
py_uwsgi_gevent_graceful(NULL, NULL);
}
struct wsgi_request *uwsgi_gevent_current_wsgi_req(void) {
PyObject *current_greenlet = GET_CURRENT_GREENLET;
PyObject *py_wsgi_req = PyObject_GetAttrString(current_greenlet, "uwsgi_wsgi_req");
@@ -372,6 +379,9 @@ void gevent_loop() {
i++;
}
// patch goodbye_cruel_world
uwsgi.gbcw_hook = uwsgi_gevent_gbcw;
// map SIGHUP with gevent.signal
PyObject *ge_signal_tuple = PyTuple_New(2);
PyTuple_SetItem(ge_signal_tuple, 0, PyInt_FromLong(SIGHUP));
+11 -2
View File
@@ -720,8 +720,7 @@ void end_me(int signum) {
exit(UWSGI_END_CODE);
}
void goodbye_cruel_world() {
void simple_goodbye_cruel_world() {
#ifdef UWSGI_THREADING
if (uwsgi.threads > 1 && !uwsgi.to_hell) {
@@ -734,6 +733,16 @@ void goodbye_cruel_world() {
exit(0);
}
void goodbye_cruel_world() {
if (!uwsgi.gbcw_hook) {
simple_goodbye_cruel_world();
}
else {
uwsgi.gbcw_hook();
}
}
#ifdef UWSGI_SPOOLER
static void uwsgi_signal_spoolers(int signum) {
+2
View File
@@ -1594,6 +1594,8 @@ struct uwsgi_server {
void (*schedule_to_main) (struct wsgi_request *);
void (*schedule_to_req) (void);
void (*gbcw_hook)(void);
int close_on_exec;
char *loop;