开发者

Could somebody give me a high-level technical overview of WSGI details behind the scenes vs other web interface approaces with Python?

Firstly:

  1. I under开发者_如何学Pythonstand what WSGI is and how to use it
  2. I understand what "other" methods (Apache mod-python, fcgi, et al) are, and how to use them
  3. I understand their practical differences

What I don't understand is how each of the various "other" methods work compared to something like UWSGI, behind the scenes. Does your server (Nginx, etc) route the request to your WSGI application and UWSGI creates a new Python interpreter for each request routed to it? How much different is is from the other more traditional / monkey patched methods is WSGI (aside from the different, easier Python interface that WSGI offers)? What light bulb moment am I missing?


Except for CGI, a new Python interpreter is nearly never created per request. Read:

http://blog.dscpl.com.au/2009/03/python-interpreter-is-not-created-for.html

This was written in respect of mod_python but also applies to mod_wsgi and any WSGI hosting mechanism that uses persistent processes.

Also read:

http://www.python.org/dev/peps/pep-0333/#environ-variables

There you will find described the 'wsgi.run_once' variable described. This is used to indicate to a WSGI application when a hosting mechanism is used which would see a process only handling one request and then being exited, ie., CGI. Thus, write a test hello world application which dumps out the WSGI environment and see what it is set to for what you are using.

Also pay attention to the 'wsgi.multiprocess' and 'wsgi.multithread' variables. They tell you if a multi process server is being used such that there are multiple instances of your application handling requests at the same time. The 'wsgi.multithread' variable tells you if the process itself is handling multiple requests in concurrent threads in same process.

For more on multiprocess and multithread models in relation to Apache embedded systems, such as mod_python and mod_wsgi, and mod_wsgi daemon mode, see:

http://code.google.com/p/modwsgi/wiki/ProcessesAndThreading

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜