Skip to content

Commit

Permalink
change the default python env allocator to holy
Browse files Browse the repository at this point in the history
  • Loading branch information
unbit committed Nov 29, 2016
1 parent fc457f8 commit 424f182
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions plugins/python/python_plugin.c
Expand Up @@ -1058,11 +1058,12 @@ void uwsgi_python_spooler_init(void) {

}

// this is the default (fake) allocator for WSGI's env
// this is the OLD default (fake) allocator for WSGI's env
// the dictionary is created on app loading (one for each async core/thread) and reused (clearing it after each request, constantly)
//
// from a python-programmer point of view it is a hack/cheat but it does not violate the WSGI standard
// and it is a bit faster than the "holy" allocator
// Starting from uWSGI 2.1 we changed the default to be the holy one in the process of having saner python defaults.
void *uwsgi_python_create_env_cheat(struct wsgi_request *wsgi_req, struct uwsgi_app *wi) {
wsgi_req->async_args = wi->args[wsgi_req->async_id];
Py_INCREF((PyObject *)wi->environ[wsgi_req->async_id]);
Expand All @@ -1073,13 +1074,10 @@ void uwsgi_python_destroy_env_cheat(struct wsgi_request *wsgi_req) {
PyDict_Clear((PyObject *)wsgi_req->async_environ);
}

// this is the "holy" allocator for WSGI's env
// this is the "holy" allocator for WSGI's env (now the default one)
// Armin Ronacher told me this is what most of python programmers expect
// I cannot speak for that as i am a perl guy, and i expect only black-magic things :P
//
// this should be the default one, but changing default behaviours (even if they are wrong)
// always make my customers going berserk...
//
// it is only slightly (better: irrelevant) slower, so no fear in enabling it...


Expand Down Expand Up @@ -1137,8 +1135,8 @@ void uwsgi_python_preinit_apps() {
}

if (!up.wsgi_env_behaviour) {
up.wsgi_env_create = uwsgi_python_create_env_cheat;
up.wsgi_env_destroy = uwsgi_python_destroy_env_cheat;
up.wsgi_env_create = uwsgi_python_create_env_holy;
up.wsgi_env_destroy = uwsgi_python_destroy_env_holy;
}
else if (!strcmp(up.wsgi_env_behaviour, "holy")) {
up.wsgi_env_create = uwsgi_python_create_env_holy;
Expand Down

0 comments on commit 424f182

Please sign in to comment.