ramkrishanbhatt / modwsgi

Automatically exported from code.google.com/p/modwsgi
0 stars 0 forks source link

WSGIImportScript causes process crash when using mod_python at same time. #91

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
If loading mod_python at same time as mod_wsgi and the LoadModule lines in 
Apache 
configuration are in the order:

  LoadModule python_module modules/mod_python.so
  LoadModule wsgi_module modules/mod_wsgi.so

and the WSGIImportScript directive is then used, then Python will fail with 
internal error:

  Fatal Python error: PyThreadState_Get: no current thread

and cause Apache child processes to crash.

The problem is caused by mod_python and mod_wsgi child process init functions 
being run in 
wrong order. Workaround is to reverse the LoadModule lines so that mod_python 
is last. This will 
cause it to be triggered first.

Alternatively, patch for mod_wsgi 2.1 is as follows:

Index: mod_wsgi.c
===========================================================
========
--- mod_wsgi.c  (revision 944)
+++ mod_wsgi.c  (working copy)
@@ -11495,15 +11495,10 @@
     static const char * const n5[] = { "mod_authz_host.c", NULL };
 #endif

-    /*
-     * Perform initialisation last in the post config phase to
-     * ensure that if mod_python is also being loaded that it
-     * gets to perform interpreter initialisation in preference
-     * to mod_wsgi doing it.
-     */
+    static const char * const p6[] = { "mod_python.c", NULL };

-    ap_hook_post_config(wsgi_hook_init, NULL, NULL, APR_HOOK_LAST);
-    ap_hook_child_init(wsgi_hook_child_init, NULL, NULL, APR_HOOK_MIDDLE);
+    ap_hook_post_config(wsgi_hook_init, p6, NULL, APR_HOOK_MIDDLE);
+    ap_hook_child_init(wsgi_hook_child_init, p6, NULL, APR_HOOK_MIDDLE);

     ap_hook_translate_name(wsgi_hook_intercept, p1, n1, APR_HOOK_MIDDLE);
     ap_hook_handler(wsgi_hook_handler, NULL, NULL, APR_HOOK_MIDDLE);

Original issue reported on code.google.com by Graham.Dumpleton@gmail.com on 17 Jul 2008 at 1:48

GoogleCodeExporter commented 8 years ago

Original comment by Graham.Dumpleton@gmail.com on 17 Jul 2008 at 1:51

GoogleCodeExporter commented 8 years ago
Version 2.2 release with change.

Original comment by Graham.Dumpleton@gmail.com on 24 Aug 2008 at 5:56