This does not make sense for most applications because you will get side effects by using reload
. Plus the time you spend on the code that detects changes and reloads all modules could have been spent on just restarting the application. It's very complicated if you import lots of modules or have a project that contains many sub-modules.
In some cases, it's a good idea though. The Django web framework provides a development server (manage.py runserver
) that automatically reloads changed modules. Take a look at the django.utils.autoreload
- it tests all Python files for modifications using the modification time of the files. As said before, this is only a good idea for some applications. Web applications are somewhat stateless and thus can be reloaded with few to no side effects.