Why avoid CGI for Python with LAMP hosting? Why avoid CGI for Python with LAMP hosting? python python

Why avoid CGI for Python with LAMP hosting?


Classic CGI isn't the best way to use anything at all. With classic CGI server has to spawn a new process for every request.

As for Python, you have few alternatives:


Why is it that using CGI is not the best way to use Python?

I will stick up for CGI a little. It's good for development environments.

It's simple to wire up and you don't have to worry about module reloading problems. Naturally performance is terrible, but for dev you don't care.

Of course you should really be writing to the WSGI interface rather than CGI directly. You can then deploy through CGI using:

wsgiref.handlers.CGIHandler().run(application)

and use the same application object to deploy through mod_wsgi other whatever other WSGI server you prefer in the production environment where speed matters (and the testing environment where you want it to be as close to production as possible).


mod_wsgi is the proper alternative. It is preferable over CGI in almost all aspects.