os.environ.setdefault: Documentation should warn against being incompatible with multiple sub interpreter processes
|Reported by:||benjaoming||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
There is a problem with the auto-generated wsgi.py because in its attempt to allow for external configurations of the environment, it should clearly warn users that it is not per default able to handle multiple environments when for instance running many virtualhosts with Apache.
With all respects to this wontfix #18518, I think the documentation should be very explicit about users configuring their DJANGO_SETTINGS_MODULE somewhere outside of wsgi.py (or editing wsgi.py). This is a very annoying bug because it shows up randomly and is very hard to debug.
"If the auto generated wsgi.py is using setdefault they have broken it very badly. When running in a multiple sub interpreter process, the first wsgi.py in any sub interpreter will win for the whole process. This is because setting os.environ, pushes values back out to process scope and when next sub interpreter is created it will pick up the value of the environment variable leaked from the other sub interpreter."