2009/6/22 yashhappy <[email protected]>: > As described at the documents, WSGIApplication directive "can be used to > specify which application group a WSGI application or set of WSGI > applications belongs to. All WSGI applications within the same application > group will execute within the context of the same Python sub interpreter. "
The statement only applies to the context of the specific process the code is executing in. If you want one sub interpreter globally, then you should only use a single process daemon process group. FWIW, if you want to have requests for an application span multiple processes, but ensure that requests for a specific user always come back to a specific sub interpreter of a specific process, then you need to use sticky sessions though use of cookies and dynamic dispatch to daemon process group process. This has been discussed previously in: http://groups.google.com/group/modwsgi/browse_frm/thread/b26ba3894632fb0a Although useful in some contexts, sticky sessions have their own drawbacks as well as discussed. Graham > In the source code, all sub interpreters are stored at a global variable > "wsgi_interpreters" and it is shared within a daemon process. I just curious > about the situation when multiple daemon processes (within the same process > group or not, whatever) are serving at the same time, WSGI applications, > which are within a same application group, will probably be execute at > different daemon process or even process group, depending on the > configuration. So at that case, WSGI applications don't execute witnin the > context of the same python sub interpreter. Considering the following cases: > > > 1. Considering the following httpd.conf file, all scripts at > /usr/wsgi/script and /usr/wsgi/script2 belong to process group www.site1.com > and www.site12.com respectively, but to the same application group > joshua_app_group_1, then all scripts at /usr/wsgi/script/ and those at > /usr/wsgi/script2/ will execute within two distinct sub interpreters whose > name are both 'joshua_app_group_1'. > > WSGIScriptAlias /wsgi/script "/usr/wsgi/script/" > WSGIScriptAlias /wsgi/script2 "/usr/wsgi/script2/" > WSGIDaemonProcess www.site2.com processes=2 threads=25 > display-name=%{GROUP} > WSGIDaemonProcess www.site1.com > processes=2 threads=25 display-name=%{GROUP} > > <Directory "/usr/wsgi/script/"> > WSGIProcessGroup www.site1.com > WSGIApplicationGroup joshua_app_group_1 > Allow from all > </Directory> > > <Directory "/usr/wsgi/script2/"> > WSGIProcessGroup www.site2.com > WSGIApplicationGroup joshua_app_group_1 > Allow from all > </Directory> > > 2. unlike the previously case, all scripts at /usr/wsgi/script/ belong to > the same process group and application group, but multiple daemon process > are still serving. It still isn't guarantee that all scripts will execute at > the same sub interpreter. Actually, two sub interpreters named > "joshua_app_group" will be created at each daemon process. Which sub > interpreter will be designated to excute the script depends on which daemon > process is designated to handle the request. > > WSGIScriptAlias /wsgi/script "/usr/wsgi/script/" > WSGIDaemonProcess www.site.com processes=2 threads=25 > display-name=%{GROUP} > <Directory "/usr/wsgi/script/"> > WSGIProcessGroup www.site.com > WSGIApplicationGroup joshua_app_group > Allow from all > </Directory> > > > So my conclusion is the scripts within the same application group "will > execute within the context of the same Python sub interpreter" if and only > if those scripts execute at a same process, daemon process(daemon mode) or > Apache child process ( embedded mode). > > Is the conclusion correct, or I just misunderstand something? Any comments > are welcome. Thanks! > > 2009-06-22 > ________________________________ > Joshua Wang > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "modwsgi" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/modwsgi?hl=en -~----------~----~----~----~------~----~------~--~---
