This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: os.environ is global for threads
Type: behavior Stage:
Components: Documentation Versions: Python 3.1, Python 3.2, Python 3.3, Python 2.7, Python 2.6
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: docs@python Nosy List: amaury.forgeotdarc, docs@python, eric.smith, georg.brandl, skrah, techtonik, zart
Priority: normal Keywords:

Created on 2010-07-21 07:07 by techtonik, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (11)
msg111013 - (view) Author: anatoly techtonik (techtonik) Date: 2010-07-21 07:07
Seems like os.environ is shared between multiple threads. This should be documented at least in threading chapters.
msg111021 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2010-07-21 08:43
I'm not sure where you'd put this. The defining characteristic of threads is that _all_ objects are shared among them.
msg111022 - (view) Author: Konstantin Zemlyak (zart) Date: 2010-07-21 08:50
Environment variables have always been process-wide. It doesn't deserve any special mention in threads documentation.
msg111033 - (view) Author: anatoly techtonik (techtonik) Date: 2010-07-21 10:09
On Wed, Jul 21, 2010 at 11:43 AM, Eric Smith <report@bugs.python.org> wrote:
>
> I'm not sure where you'd put this. The defining characteristic of threads is that _all_ objects are shared among them.

Where is this defining characteristic of threads is described?
msg111035 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2010-07-21 10:31
>> I'm not sure where you'd put this. The defining characteristic of threads is that _all_ objects are shared among them.
> Where is this defining characteristic of threads is described?

in http://docs.python.org/library/thread.html
"""...multiple threads of control sharing their global data space..."""

That's how threads are understood in all programming languages.
msg111037 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-07-21 11:05
Closing in agreement with Eric/Amaury.
msg111100 - (view) Author: anatoly techtonik (techtonik) Date: 2010-07-21 18:35
> in http://docs.python.org/library/thread.html
> """...multiple threads of control sharing their global data space..."""
>
> That's how threads are understood in all programming languages.

Do you mean this one?

"""This module provides low-level primitives for working with multiple threads (also called light-weight processes or tasks) — multiple threads of control sharing their global data space.""" 

It is surely confusing and doesn't explain anything to people who never worked with threads (like me). It should either be split in two sentences or simplified.

http://en.wikipedia.org/wiki/Thread_(computer_science) says that threads can share resources, but not necessarily do so.
msg111128 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2010-07-21 22:19
Quoting the wikipedia page: """multiple threads within a process share state as well as memory and other resources"""

If you never worked with threads, then you really need a tutorial about threads, or even a general explanation about threads; the reference manual is not such a place.
Programming with threads has really complex aspects that are not inherent to Python.

[Some people will also say: if you never worked with threads, don't start]
msg111162 - (view) Author: anatoly techtonik (techtonik) Date: 2010-07-22 10:15
I have to debug CGIHTTPServer test case that apparently uses threads, and I expected to find at least some pointer about "what exactly a thread in Python is". I hope Python Manual is not only for system programmers. They do not need the manual anyway - they already know everything and there are plenty tutorials for them elsewhere.

-- 
"please remove http://docs.python.org/ and put in a better documentation, I wasted so much time reading that bad documentation that now I hate it and I will never write code in python" (c) Mario Santamaria
msg111163 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2010-07-22 10:23
I agree with Eric, Konstantin, Amaury and Georg. Closing for the third time.
msg111165 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-07-22 10:37
Anatoly, I don't think it is a good idea to use signatures in tracker comments.
History
Date User Action Args
2022-04-11 14:57:04adminsetgithub: 53566
2010-07-22 10:37:54georg.brandlsetmessages: + msg111165
2010-07-22 10:23:49skrahsetstatus: open -> closed
2010-07-22 10:23:28skrahsetstatus: pending -> open
nosy: + skrah
messages: + msg111163

2010-07-22 10:15:14techtoniksetstatus: closed -> pending

messages: + msg111162
2010-07-21 22:19:27amaury.forgeotdarcsetstatus: pending -> closed

messages: + msg111128
2010-07-21 18:35:35techtoniksetstatus: closed -> pending

messages: + msg111100
2010-07-21 11:05:19georg.brandlsetstatus: open -> closed

nosy: + georg.brandl
messages: + msg111037

resolution: works for me
2010-07-21 10:31:11amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg111035
2010-07-21 10:09:10techtoniksetmessages: + msg111033
2010-07-21 08:50:20zartsetnosy: + zart
messages: + msg111022
2010-07-21 08:43:35eric.smithsetnosy: + eric.smith
messages: + msg111021
2010-07-21 07:07:23techtonikcreate