Starting the process in daemon mode will not help. Here's what happens:
mod_wsgi generates several identical processes to handle incoming requests for your Django site. Each of these processes is its own Python interpreter and can process an incoming web request. These processes are permanent (they are not brought up and do not break down for each request), so one process can process thousands of requests one after another. mod_wsgi is able to handle several web requests at the same time, since there are several processes.
Each Python interpreter process will load your modules (your custom Python files) whenever an "import module" is executed. In the django context, this will happen when a new view.py is needed due to a web request. Once the module is loaded, it is in memory, so any changes you make to the file will not be reflected in this process. As more web requests arrive, the Python process interpreter will simply use the version of the module that is already loaded into memory. You see discrepancies between updates, as each web request you make can be handled by different processes. Some processes may have loaded your Python modules during previous changes to your code, while others may have loaded them later (because these processes did not receive a web request).
A simple solution: every time you change your code, restart the Apache process. In most cases, it is as simple as launching root from the "restart / etc / init.d / apache2" shell. I believe that a simple reboot also works, which is faster, "/etc/init.d/apache2 reload"
Daemon solution: if you use mod_wsgi in daemon mode, all you have to do is click (unix command) or modify the wsgi script file. To clarify the scrompt.com message, changes to the Python source code will not cause mod_wsgi to reload your code. Rebooting occurs only when the wsgi script file has been modified.
One final note: I only talked about wsgi as using processes for simplicity. wsgi actually uses thread pools within each process. I did not feel this detail was relevant to this answer, but you can learn more by reading mod_wsgi .
Braincore
source share