[issue41660] multiprocessing.Manager objects lose connection info
Tim Peters
report at bugs.python.org
Fri Aug 28 22:27:23 EDT 2020
Tim Peters <tim at python.org> added the comment:
Weird. If I insert these between the two process starts:
import time
time.sleep(2)
then the producer produces the expected output:
at start: 666
at producer start: 666
and the program blows up instead when it gets to
print("in consumer:", self.val.value)
Same thing if, instead of a sleep, I put
producerprocess.join()
before starting the consumer.
If I change the tail end to:
producerprocess.start()
import time
time.sleep(2)
print(state_value)
consumerprocess = MyConsumer(state_value, state_ready)
consumerprocess.start()
then I see
at start: 666
at producer start: 666
Value('i', 42)
before it blows up in the consumer. So `state_value` appears to survive intact, and mutated as intended, across the producer's life - but gets corrupted somehow when it's _also_ passed to the consumer.
Weirder ;-) , if I replace the tail with the ever-more elaborate:
producerprocess = MyProducer(state_value, state_ready)
producerprocess.start()
import time
time.sleep(2)
producerprocess.join()
print(state_value)
state_value.value = 13
producerprocess = MyProducer(state_value, state_ready)
producerprocess.start()
time.sleep(2)
producerprocess.join()
print(state_value)
consumerprocess = MyConsumer(state_value, state_ready)
consumerprocess.start()
then I see
at start: 666
at producer start: 666
Value('i', 42)
at producer start: 13
Value('i', 42)
before it blows up in the consumer - so it survived two full producer lifetimes! So ... generalize ... change the tail to:
for i in range(10):
state_value.value = i
producerprocess = MyProducer(state_value, state_ready)
producerprocess.start()
producerprocess.join()
print(state_value)
consumerprocess = MyConsumer(state_value, state_ready)
consumerprocess.start()
and I see everything working fine before it blows up in the consumer:
at start: 666
at producer start: 0
Value('i', 42)
at producer start: 1
Value('i', 42)
at producer start: 2
Value('i', 42)
at producer start: 3
Value('i', 42)
at producer start: 4
Value('i', 42)
at producer start: 5
Value('i', 42)
at producer start: 6
Value('i', 42)
at producer start: 7
Value('i', 42)
at producer start: 8
Value('i', 42)
at producer start: 9
Value('i', 42)
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41660>
_______________________________________
More information about the Python-bugs-list
mailing list