-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
Closed as not planned
Labels
stdlibPython modules in the Lib dirPython modules in the Lib dirtopic-multiprocessingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
Expected: 0, 1, 2 or 0, 10, 11 or 0, 10, 100, 2, 1000, 101 or 0, 1, 2, 20 etc...
Actual: 0, 10, 200
Python version 3.12
Code for minimal reproduction:
import multiprocessing
from threading import Thread
import time
class MyThread(Thread):
def __init__(self, test_dict, **kwargs):
super().__init__(**kwargs)
self.test_dict = test_dict
def run(self):
time.sleep(1)
while True:
self.test_dict["test"] += 1
time.sleep(1)
class AProcess(multiprocessing.Process):
def __init__(self, test_dict, **kwargs):
super().__init__(**kwargs)
self.test_dict = test_dict
def run(self):
time.sleep(1)
while True:
self.test_dict["test"] *= 10
time.sleep(1)
class PrintThread(Thread):
def __init__(self, test_dict, **kwargs):
super().__init__(**kwargs)
self.test_dict = test_dict
def run(self):
while True:
time.sleep(0.1)
print(self.test_dict["test"])
if __name__ == "__main__":
manager = multiprocessing.Manager()
test_dict = manager.dict({"test": 0})
ts = [
MyThread(test_dict=test_dict, daemon=True),
PrintThread(test_dict=test_dict, daemon=True),
]
for t in ts:
t.start()
p = AProcess(test_dict)
p.start()
time.sleep(2)
test_dict["test"] = 20
for t in ts:
t.join()
p.join()
CPython versions tested on:
3.12
Operating systems tested on:
Linux
Metadata
Metadata
Assignees
Labels
stdlibPython modules in the Lib dirPython modules in the Lib dirtopic-multiprocessingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error