From bdf533d62b6f36b00a2f011ab2a28563e9a6b592 Mon Sep 17 00:00:00 2001 From: "roberto@precise64" Date: Thu, 26 Apr 2012 14:51:39 +0200 Subject: [PATCH] fixed auto-reloading --- plugins/python/python_plugin.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/plugins/python/python_plugin.c b/plugins/python/python_plugin.c index f26942e4..8dd57a35 100644 --- a/plugins/python/python_plugin.c +++ b/plugins/python/python_plugin.c @@ -1196,22 +1196,15 @@ void uwsgi_python_init_thread(int core_id) { } #ifdef UWSGI_THREADING -int uwsgi_check_python_mtime(PyObject *times_dict, uint64_t cycles, char *filename) { +int uwsgi_check_python_mtime(PyObject *times_dict, char *filename) { struct stat st; PyObject *py_mtime = PyDict_GetItemString(times_dict, filename); if (!py_mtime) { - if (cycles == 0) { - if (stat(filename, &st)) { - return 0; - } - PyDict_SetItemString(times_dict, filename, PyLong_FromLong(st.st_mtime)); - } - else { - uwsgi_log("[uwsgi-python-reloader] found new module/file: %s\n", filename); - kill(uwsgi.workers[0].pid, SIGHUP); - return 1; + if (stat(filename, &st)) { + return 0; } + PyDict_SetItemString(times_dict, filename, PyLong_FromLong(st.st_mtime)); } // the record is already tracked; else { @@ -1277,7 +1270,6 @@ cycle: } PyObject *times_dict = PyDict_New(); char *filename; - uint64_t cycles = 0; for(;;) { UWSGI_RELEASE_GIL; sleep(up.auto_reload); @@ -1323,7 +1315,7 @@ cycle: else { filename = uwsgi_concat2(mod_filename, ""); } - if (uwsgi_check_python_mtime(times_dict, cycles, filename)) { + if (uwsgi_check_python_mtime(times_dict, filename)) { UWSGI_RELEASE_GIL; return NULL; } @@ -1332,7 +1324,6 @@ cycle: Py_DECREF(zero); #endif } - cycles++; } return NULL;