How to solve your bytecode problem
You should probably find out why these unwanted .pyc files are in the first place (are they in your repository? Should they be ignored).
As mentioned in the comments, if you have tattered .pyc files that cause problems, you can enable the deletion of all .pyc files as part of the pull process when deploying newer code to the server. Running the application will lead to the re-creation of those that are necessary when importing the modules.
Now, if you really do not want to generate bytecode, you can use the PYTHONDONTWRITEBYTECODE environment PYTHONDONTWRITEBYTECODE , but I would not want t recommend it, as this seems like a pretty overkill solution.
How to solve Apache, apparently pulling out old versions of code.
Now you need to make the difference between the two problems when playing here.
- Older Bytecode files generated by a python file (e.g.
.pyc ), which can cause a problem in certain cases, such as replacing a file with a module, but it is often a concern. - The WSGI mod does not reload the new code that is loading. It depends on the mode in which you start Mod WSGi, and the usual symptom is that hitting the page seems to randomly pull out a new or older version of the code.
To solve the first problem , you just need to delete the unused bytecode files. But, again, this is probably not the cause of your problem.
To solve the second problem , you have two solutions
- Restarting apache when loading new code. Using
apache2ctl -k graceful , this will be transparent to your users, and I don’t understand why “server rebooting can be a problem” if you are not using shared hosting. - Using code reloading, you can see the
mod_wsgi documentation .
I don’t think that bytecode is your problem, and probably reloading the code.
Thomas Orozco 01 Oct '12 at 11:02 2012-10-01 11:02
source share