Opened 3 years ago

Closed 3 years ago

#18559 closed Bug (duplicate)

os.environ.setdefault: Documentation should warn against being incompatible with multiple sub interpreter processes

Reported by: benjaoming Owned by: nobody
Component: Documentation Version: 1.4
Severity: Normal Keywords: os.environ wsgi
Cc: grahamd Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no


There is a problem with the auto-generated 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 (or editing This is a very annoying bug because it shows up randomly and is very hard to debug.

As the author of modwsgi notes:

"If the auto generated is using setdefault they have broken it very badly. When running in a multiple sub interpreter process, the first 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."

Change History (2)

comment:1 Changed 3 years ago by grahamd

  • Cc grahamd added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 3 years ago by russellm

  • Resolution set to duplicate
  • Status changed from new to closed

Moving the discussion back to #18518, since it's the same issue, reopened as a different ticket because of the wontfix. The documentation approach proposed here *might* be the eventual solution to #18518.

Note: See TracTickets for help on using tickets.
Back to Top