implemented workerN signal target

This commit is contained in:
roberto@maverick64
2011-07-03 12:55:18 +02:00
parent 0ba1b982d1
commit e08b2cccf9
3 changed files with 23 additions and 6 deletions
+6
View File
@@ -43,6 +43,9 @@ cycle:
uwsgi_error("read()");
}
else {
if (uwsgi_signal_handler(received_signal)) {
uwsgi_log_verbose("error managing signal %d on worker %d\n", received_signal, uwsgi.mywid);
}
wsgi_req->signal_received = received_signal;
if (wait_for_specific_signal) {
if (received_signal != uwsgi_signal) goto cycle;
@@ -54,6 +57,9 @@ cycle:
uwsgi_error("read()");
}
else {
if (uwsgi_signal_handler(received_signal)) {
uwsgi_log_verbose("error managing signal %d on worker %d\n", received_signal, uwsgi.mywid);
}
wsgi_req->signal_received = received_signal;
if (wait_for_specific_signal) {
if (received_signal != uwsgi_signal) goto cycle;
+12 -6
View File
@@ -172,6 +172,17 @@ void uwsgi_route_signal(uint8_t sig) {
}
}
}
// route to specific worker
else if (!strncmp(use->receiver, "worker", 6)) {
i = atoi(use->receiver+6);
if (i > uwsgi.numproc) {
uwsgi_log("invalid signal target: %s\n", use->receiver);
}
if (write(uwsgi.workers[i].signal_pipe[0], &sig, 1) != 1) {
uwsgi_error("write()");
uwsgi_log("could not deliver signal %d to worker %d\n", sig, i);
}
}
// route to subscribed
else if (!strcmp(use->receiver, "subscribed")) {
}
@@ -186,11 +197,6 @@ void uwsgi_route_signal(uint8_t sig) {
}
else {
// unregistered signal, sending it to all the workers
uwsgi_log("^^^ ROUTING UNREGISTERED SIGNAL ^^^\n");
if (write(ushared->worker_signal_pipe[0], &sig, 1) != 1) {
uwsgi_error("write()");
uwsgi_log("could not deliver signal %d to workers pool\n", sig);
}
uwsgi_log("^^^ UNSUPPORTED SIGNAL TARGET: %s ^^^\n", use->receiver);
}
}
+5
View File
@@ -5,6 +5,10 @@ from uwsgidecorators import *
def hello(signum):
print("I AM THE WORKER %d" % uwsgi.worker_id())
@signal(30, target='worker2')
def hello2(signum):
print("I AM THE WORKER 2")
@postfork
def wait_for_signal():
if uwsgi.worker_id() != 2:
@@ -17,6 +21,7 @@ def application(e, s):
s('200 OK', [('Content-Type', 'text/html')])
if e['PATH_INFO'] == '/30':
uwsgi.signal(30)
uwsgi.signal(100)
else:
uwsgi.signal(17)
return "Signal raised"