Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mod_wsgi daemon mode, WSGIApplicationGroup and Python interpreter separation

I have Apache with 2 virtual hosts, each having a Django site attached using mod_wsgi, daemon mode, like this:

<VirtualHost 123.123.123.123:80>
    WSGIDaemonProcess a.com user=x group=x processes=5 threads=1
    WSGIProcessGroup a.com
    WSGIApplicationGroup %{GLOBAL}
</VirtualHost>

<VirtualHost 123.123.123.123:80>
    WSGIDaemonProcess b.com user=x group=x processes=5 threads=1
    WSGIProcessGroup b.com
    WSGIApplicationGroup %{GLOBAL}
</VirtualHost>

I use WSGIApplicationGroup %{GLOBAL} because of a known problem with Xapian.

Now, if I understand what's going on behind the scenes, mod_wsgi launches 5 daemon processes for each of my sites. I can see this in Apache log:

[info] mod_wsgi (pid=8106): Attach interpreter ''.
[info] mod_wsgi (pid=8106): Adding '.../lib/python2.5/site-packages' to path.
[info] mod_wsgi (pid=8106): Enable monitor thread in process 'a.com'.
[info] mod_wsgi (pid=8106): Enable deadlock thread in process 'a.com'.

[info] mod_wsgi (pid=8107): Attach interpreter ''.
[info] mod_wsgi (pid=8107): Adding '.../lib/python2.5/site-packages' to path.
[info] mod_wsgi (pid=8107): Enable monitor thread in process 'a.com'.
[info] mod_wsgi (pid=8107): Enable deadlock thread in process 'a.com'.

...

What I don't understand is if those "Attach interpreter ''" lines indicate that all of those processes share the same Python interpreter, or if there is one interpreter per process. (BTW I realize that the empty interpreter name '' is caused by passing %{GLOBAL} to WSGIApplicationGroup).

I tried checking if maybe sys.path entries cumulated in subsequent processes, but they didn't - which could indicate that there's a separate Python interpreter for each of the 5 daemon processes... but I don't quite understand all these things so I'm asking here.

like image 693
Tomasz Zieliński Avatar asked Feb 16 '11 19:02

Tomasz Zieliński


1 Answers

The 'pid' value is different. They are in different processes.

like image 53
Graham Dumpleton Avatar answered Nov 15 '22 04:11

Graham Dumpleton