From 2bf20631e1992c7fea478d6827ccec7ccf1467dd Mon Sep 17 00:00:00 2001 From: "roberto@sirius" Date: Fri, 1 Oct 2010 11:50:00 +0200 Subject: [PATCH] stabilization fixes --- pyloader.c | 13 +++++++++---- uwsgi.c | 4 ---- wsgi_handlers.c | 5 ++--- xmlconf.c | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pyloader.c b/pyloader.c index 9f593924..b55b6217 100644 --- a/pyloader.c +++ b/pyloader.c @@ -79,7 +79,6 @@ int init_uwsgi_app(int loader, void *arg1, struct uwsgi_server *uwsgi, int new_i // Initialize a new environment for the new interpreter if (new_interpreter && id) { - uwsgi_log("setting new interpreter\n"); wi->interpreter = Py_NewInterpreter(); if (!wi->interpreter) { uwsgi_log( "unable to initialize the new python interpreter\n"); @@ -94,12 +93,15 @@ int init_uwsgi_app(int loader, void *arg1, struct uwsgi_server *uwsgi, int new_i #endif init_uwsgi_vars(); } + else { + wi->interpreter = uwsgi->main_thread; + } wi->wsgi_callable = uwsgi->loaders[loader](arg1); if (!wi->wsgi_callable) { - uwsgi_log("unable to find \"%.*s\" callable\n", wsgi_req->wsgi_callable_len, wsgi_req->wsgi_callable); + uwsgi_log("unable to load app SCRIPT_NAME=%s\n", mountpoint); goto doh; } @@ -140,6 +142,9 @@ int init_uwsgi_app(int loader, void *arg1, struct uwsgi_server *uwsgi, int new_i } } + // avoid __code__ attr error propagation + PyErr_Clear(); + if (zero) { zero = PyObject_GetAttrString(zero, "co_argcount"); wi->argc = (int) PyInt_AsLong(zero); @@ -216,10 +221,10 @@ int init_uwsgi_app(int loader, void *arg1, struct uwsgi_server *uwsgi, int new_i } if (wi->argc == 1) { - uwsgi_log( "Web3 application %d (SCRIPT_NAME=%.*s) ready", id, wi->mountpoint_len, wi->mountpoint); + uwsgi_log( "Web3 application %d (SCRIPT_NAME=%.*s) ready on interpreter %p", id, wi->mountpoint_len, wi->mountpoint, wi->interpreter); } else { - uwsgi_log( "WSGI application %d (SCRIPT_NAME=%.*s) ready", id, wi->mountpoint_len, wi->mountpoint); + uwsgi_log( "WSGI application %d (SCRIPT_NAME=%.*s) ready on interpreter %p", id, wi->mountpoint_len, wi->mountpoint, wi->interpreter); } if (id == 0) { diff --git a/uwsgi.c b/uwsgi.c index c1abf4a5..aa482d3c 100644 --- a/uwsgi.c +++ b/uwsgi.c @@ -1609,8 +1609,6 @@ void init_uwsgi_vars() { PyObject *site_module; #endif - uwsgi_log("AAAAAAA\n"); - /* add cwd to pythonpath */ pysys = PyImport_ImportModule("sys"); if (!pysys) { @@ -1628,8 +1626,6 @@ void init_uwsgi_vars() { // simulate a pythonhome directive if (uwsgi.wsgi_req->pyhome_len > 0) { - uwsgi_log("TEST000\n"); - PyObject *venv_path = UWSGI_PYFROMSTRINGSIZE(uwsgi.wsgi_req->pyhome, uwsgi.wsgi_req->pyhome_len) ; #ifdef UWSGI_DEBUG diff --git a/wsgi_handlers.c b/wsgi_handlers.c index dc7c962b..5fbcd049 100644 --- a/wsgi_handlers.c +++ b/wsgi_handlers.c @@ -188,8 +188,7 @@ int uwsgi_request_wsgi(struct uwsgi_server *uwsgi, struct wsgi_request *wsgi_req wi = &uwsgi->apps[wsgi_req->app_id]; - if (uwsgi->single_interpreter == 0 && wsgi_req->app_id) { - uwsgi_log("SWAPPING INTERPRETER\n"); + if (uwsgi->single_interpreter == 0 && wsgi_req->app_id > 0) { if (!wi->interpreter) { internal_server_error(wsgi_req->poll.fd, "wsgi application's %d interpreter not found"); goto clear2; @@ -358,7 +357,7 @@ int uwsgi_request_wsgi(struct uwsgi_server *uwsgi, struct wsgi_request *wsgi_req clear: - if (uwsgi->single_interpreter == 0 && wsgi_req->app_id) { + if (uwsgi->single_interpreter == 0 && wsgi_req->app_id > 0) { // restoring main interpreter PyThreadState_Swap(uwsgi->main_thread); } diff --git a/xmlconf.c b/xmlconf.c index 5b4ad502..354559f7 100644 --- a/xmlconf.c +++ b/xmlconf.c @@ -194,7 +194,7 @@ next: continue; } - //init_uwsgi_app(&uwsgi, PyDict_GetItemString(uwsgi.pyloader_dict, (char *) node2->children->content) ); + init_uwsgi_app(LOADER_STRING_CALLABLE, (void *) node2->children->content, &uwsgi, uwsgi.single_interpreter-1); } else if (!strcmp((char *) node2->name, "eval")) { if (!node2->children) {