-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
Closed as not planned
Labels
stdlibPython modules in the Lib dirPython modules in the Lib dirtestsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
I ran it multiple times with the following code and got different results
import os
import threading
import time
from test.support.os_helper import EnvironmentVarGuard
def worker1(guard):
for i in range(1000):
guard['MY_VAR'] = f'value1'
time.sleep(0.0001) # Small delay to increase chance of thread switching
def worker2(guard):
for i in range(1000):
guard['MY_VAR'] = f'value2'
time.sleep(0.0001)
guard = EnvironmentVarGuard()
t1 = threading.Thread(target=worker1, args=(guard,))
t2 = threading.Thread(target=worker2, args=(guard,))
t1.start()
t2.start()
t1.join()
t2.join()
final_value = os.getenv('MY_VAR')
print(f"Final value: {final_value}")
This issue I found in #131870, adding a lock to the test_zoneinfo.py,
but the original implementation didn't.
BTW, 131870 PR has not been reviewed by anyone yet (more a week)
CPython versions tested on:
3.14, 3.13
Operating systems tested on:
Windows
Linked PRs
Metadata
Metadata
Assignees
Labels
stdlibPython modules in the Lib dirPython modules in the Lib dirtestsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error