We presently operate a small hosting that is shared service for a few hundred small PHP sites on our servers. We want to provide Python support too, but from your initial research a minimum of, a server restart appears to become needed after each source code change.

Is truly the situation? If that's the case, we are simply not likely to have the ability to offer Python hosting support. Giving our clients a chance to upload files is simple, but we can not ask them to restart the (shared) server process!

PHP is simple -- you upload a brand new version of the file, the brand new version operates.

I have lots of respect for that Python language and community, so fight to think that it requires this type of crazy process to update a site's code. Please let me know I am wrong! :-)

Python is really a put together language the put together byte code is cached through the Python process later, to enhance performance. PHP, automatically, is construed. It is a tradeoff between usability and speed.

If you are utilizing a standard WSGI module, for example Apache's mod_wsgi, then it's not necessary to restart the server -- just touch the .wsgi file and also the code is going to be reloaded. If you are with a couple strange server which does not support WSGI, you are kind of by yourself usability-smart.

Is dependent how you deploy the Python application. If it's like a pure Python CGI script, no restarts are essential (not suggested whatsoever though, because it will likely be super slow). If you work with modwsgi in Apache, you will find valid methods for reloading the origin. modpython apparently has some support and associated issues for module reloading.

You will find ways apart from Apache to host Python application, such as the CherryPy server, Paste Server, Zope, Twisted, and Tornado.

However, unless of course you've got a specific reason to not utilize it (an as you are originating from most probably an Apache/PHP shop), I'd highly recommed mod_wsgi on Apache. I understand that Django suggests modwsgi on Apache and the majority of the other major Python frameworks works on modwsgi.

Is truly the situation?

It Is dependent. Code reloading is extremely specific towards the hosting solution. Most servers provide a way to instantly reload the WSGI script itself, there is however no standardisation indeed, the question of methods a WSGI Application object is attached to an internet server whatsoever differs broadly across different hosting conditions. (You are able to nearly create a single script file that actually works as deployment glue for CGI, mod_wsgi, passenger and ISAPI_WSGI, but it is not wholly trivial.)

What Python really struggles with, though, is module reloading. That is problematic for WSGI programs because any non-trivial webapp is going to be encapsulating its functionality into modules and packages instead of simple stand alone scripts. It works out reloading modules is very tricky, if you reload() them 1 by 1 they are able to easily finish track of bad references to old versions. Ideally the way in which forward is always to reload the entire Python interpreter when any file is up-to-date, but used it appears some C extensions appear to not such as this therefore it is not generally done.

You will find workarounds to reload several modules at the same time which could dependably update a credit card applicatoin when among its modules is touched. I personally use a deployment module that performs this (that we don't have around to posting, but could chuck a copy if you are interested) and delay pills work ideal for my very own webapps. But you will need some discipline to make certain you do not accidentally start departing references for your old modules' objects in other modules you are not reloading if you are speaking lots of sites compiled by organizations whose code might be leaking, this is probably not ideal.

For the reason that situation you might like to take a look at something similar to running mod_wsgi in daemon mode by having an application group for every party and process-level reloading, and touch the WSGI script file when you have up-to-date the modules.

You are to complain this (and several other WSGI deployment issues) could use some standardisation help.