Hello,
attached a couple of patches to add some more spooler related data to
uwsgi python module:
- one add a switch to know if we have the spooler available and then we
can query for its data.
- the other one export the spooler pid to python.
Diffed against latest stable 0.9.6.5, please review.
thanks,
riccardo
--- uwsgi.old.c 2010-09-29 07:57:43.000000000 +0200
+++ uwsgi.c 2010-10-28 18:30:06.102523714 +0200
@@ -1234,6 +1234,9 @@
if (uwsgi.spool_dir != NULL && uwsgi.numproc > 0) {
uwsgi.shared->spooler_pid = spooler_start(uwsgi.serverfd, uwsgi.embedded_dict);
}
+
+ /* We don't care if it fails, we have already set it to false */
+ PyDict_SetItemString(uwsgi.embedded_dict, "has_spooler", uwsgi.shared->spooler_pid ? Py_True : Py_False)
#endif
#ifdef UWSGI_STACKLESS
@@ -2955,6 +2958,10 @@
}
#endif
+ if (PyDict_SetItemString(uwsgi.embedded_dict, "has_spooler", Py_False)) {
+ PyErr_Print();
+ exit(1);
+ }
if (uwsgi.sharedareasize > 0 && uwsgi.sharedarea) {
init_uwsgi_module_sharedarea(new_uwsgi_module);
--- uwsgi_pymodule.old.c 2010-10-28 16:41:08.650649361 +0200
+++ uwsgi_pymodule.c 2010-10-28 16:41:15.991903940 +0200
@@ -518,6 +518,13 @@
Py_INCREF(Py_None);
return Py_None;
}
+
+PyObject *py_uwsgi_spoolerpid(PyObject * self, PyObject * args) {
+ if (uwsgi->shared.spooler_pid) {
+ return PyInt_FromLong(uwsgi->shared.spooler_pid);
+ }
+ return PyInt_FromLong(0);
+}
#endif
PyObject *py_uwsgi_send_multi_message(PyObject * self, PyObject * args) {
@@ -1138,6 +1145,7 @@
{"send_to_spooler", py_uwsgi_send_spool, METH_VARARGS, ""},
{"set_spooler_frequency", py_uwsgi_spooler_freq, METH_VARARGS, ""},
{"spooler_jobs", py_uwsgi_spooler_jobs, METH_VARARGS, ""},
+ {"spoolerpid", py_uwsgi_spoolerpid, METH_VARARGS, ""},
{NULL, NULL},
};
#endif
_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi