Here\'s some sample code that is reads a file and adds up each line. It is supposed to add up all the numbers from 0-20. However, I always get a result of 0.
0
You can accomplish this using shared memory with subprocess.Value, just change your Total class to the following:
subprocess.Value
Total
class Total(): def __init__(self): self.total = multiprocessing.Value('d', 0) def add(self, number): self.total.value += int(number) def __str__(self): return str(self.total.value)