From 48e13bfc65fb1f98c1db598af4d7d2a365d5907e Mon Sep 17 00:00:00 2001 From: Roberto De Ioris Date: Sat, 15 Mar 2014 08:48:07 +0100 Subject: [PATCH] add a check for already initialized python vm --- plugins/python/python_plugin.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/python/python_plugin.c b/plugins/python/python_plugin.c index daae72f7..1f8e4edc 100644 --- a/plugins/python/python_plugin.c +++ b/plugins/python/python_plugin.c @@ -197,6 +197,12 @@ int uwsgi_python_init() { uwsgi_log_initial("Python version: %.*s %s\n", pyversion-Py_GetVersion(), Py_GetVersion(), Py_GetCompiler()+1); } + if (Py_IsInitialized()) { + uwsgi_log("--- Python VM already initialized ---\n"); + PyGILState_Ensure(); + goto ready; + } + if (up.home != NULL) { #ifdef PYTHREE // check for PEP 405 virtualenv (starting from python 3.3) @@ -251,6 +257,8 @@ pep405: Py_Initialize(); +ready: + if (!uwsgi.has_threads) { uwsgi_log_initial("*** Python threads support is disabled. You can enable it with --enable-threads ***\n"); }