Have a read of: http://code.google.com/p/modwsgi/wiki/ProcessesAndThreading http://blog.dscpl.com.au/2009/03/python-interpreter-is-not-created-for.html
The latter was originally about mod_python, but the same applies to mod_wsgi. In short, the Python interpreter is not executed as a separate process. The interpreter runs embedded inside of the existing Apache child worker processes. The interpreter instance in memory is retained between requests and will survive as long as the Apache child worker process stays around. In daemon mode it is effectively the same, with exception that mod_wsgi (within Apache) creates a separate persistent child process independent of the Apache child worker processes. Graham On 03/04/2014, at 12:18 AM, james hedley <[email protected]> wrote: > Hi > > Just out of curiosity, really. > > I'm running mod_wsgi 3.2 under Apache/2.2.15 on RHEL 6.4, Apache is set to > prefork and mod_wsgi is running in embedded mode. IOW, default config. Can > provide more details if needed. > > So I was asked about whether each request gets a clean python interpreter, to > which I said "I'm not sure but I can find out". > > So then I added some crummy debug code to my mod_wsgi script: > > > interface = Interface() > > application = interface.wsgi > > class Interface(object): > "Interface is used to expose method calls." > def __init__(self): > p = PrintPid() > self._lookup = dict() > .... > def wsgi(self, environment, start_response): > ... > > class PrintPid(object): > def __init__(self): > h = open('/tmp/apache_pids', 'a') > h.write(str(os.getpid())) > h.write('\n') > h.close() > > After doing a few dozen requests, as I expected, /tmp/apache_pids had about > the same list of pids as I get from "ps -ef | grep httpd". > > However, I don't see any python processes running in between requests. > > So, the question is, does that mean PrintPid only gets instantiated once per > apache worker process? Could that then mean that state could persist between > requests?? > > Also, does embedded mode mean the python interpreter can hide from 'ps'? > > Any help appreciated. > > James > > > > -- > You received this message because you are subscribed to the Google Groups > "modwsgi" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/modwsgi. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "modwsgi" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/modwsgi. For more options, visit https://groups.google.com/d/optout.
