From 91273b230100d5ca15536b95f21d4bbc5c448abc Mon Sep 17 00:00:00 2001 From: "roberto@precise64" Date: Sat, 14 Apr 2012 11:48:27 +0200 Subject: [PATCH] py-auto-reload-ignore --- plugins/python/python_plugin.c | 11 +++++++++++ plugins/python/uwsgi_python.h | 1 + 2 files changed, 12 insertions(+) diff --git a/plugins/python/python_plugin.c b/plugins/python/python_plugin.c index a0aa3b55..8b32dc34 100644 --- a/plugins/python/python_plugin.c +++ b/plugins/python/python_plugin.c @@ -124,6 +124,7 @@ struct uwsgi_option uwsgi_python_options[] = { {"py-autoreload", required_argument, 0, "monitor python modules mtime to trigger reload (use only in development)", uwsgi_opt_set_int, &up.auto_reload, UWSGI_OPT_THREADS|UWSGI_OPT_MASTER}, {"python-auto-reload", required_argument, 0, "monitor python modules mtime to trigger reload (use only in development)", uwsgi_opt_set_int, &up.auto_reload, UWSGI_OPT_THREADS|UWSGI_OPT_MASTER}, {"python-autoreload", required_argument, 0, "monitor python modules mtime to trigger reload (use only in development)", uwsgi_opt_set_int, &up.auto_reload, UWSGI_OPT_THREADS|UWSGI_OPT_MASTER}, + {"py-auto-reload-ignore", required_argument, 0, "ignore the specified module during auto-reload scan (can be specified multiple times)", uwsgi_opt_add_string_list, &up.auto_reload_ignore, UWSGI_OPT_THREADS|UWSGI_OPT_MASTER}, #endif {0, 0, 0, 0, 0, 0, 0}, @@ -1281,6 +1282,16 @@ cycle: #endif PyObject *mod_name, *mod; while (PyDict_Next(modules, &pos, &mod_name, &mod)) { + int found = 0; + struct uwsgi_string_list *usl = up.auto_reload_ignore; + while(usl) { + if (!strcmp(usl->value, PyString_AsString(mod_name))) { + found = 1; + break; + } + usl = usl->next; + } + if (found) continue; if (!PyObject_HasAttrString(mod, "__file__")) continue; PyObject *mod_file = PyObject_GetAttrString(mod, "__file__"); if (!mod_file) continue; diff --git a/plugins/python/uwsgi_python.h b/plugins/python/uwsgi_python.h index a235d771..275a2798 100644 --- a/plugins/python/uwsgi_python.h +++ b/plugins/python/uwsgi_python.h @@ -160,6 +160,7 @@ struct uwsgi_python { void (*gil_get) (void); void (*gil_release) (void); int auto_reload; + struct uwsgi_string_list *auto_reload_ignore; #endif PyObject *workers_tuple;