2

One parent launch two process A, B with python multiprocessing that should run in parallel.

Share two lists with Multiprocessing.Manager list_1 list_2

A write to list_1 that is passed as parameter to A, inside A list_1 became list_W. A read from a list_2 that is passed as parameter to A, inside A list_2 became list_R B write to list_2 that is passed as parameter to B, inside B list_2 became list_W. B read from a list_1 that is passed as parameter to B, inside B list_1 became list_R

if I call A or B not as multiprocessing.process but as single function, they run, whitout problems.

if I call them as multiprocessing.process this is what happen:

Traceback (most recent call last):
  File "/usr/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
    self.run()
  File "/usr/lib/python2.7/multiprocessing/process.py", line 114, in run
    self._target(*self._args, **self._kwargs)
  File "myprg/A.py", line 47, in A
    watch()                                                         
  File "myprg/DEFINITIONS.py", line 87, in watch
    if list_W[0] != list_R[0]:
  File "<string>", line 2, in __getitem__
  File "/usr/lib/python2.7/multiprocessing/managers.py", line 759, in _callmethod
    kind, result = conn.recv()
IOError: [Errno 104] Connection reset by peer

The watch() compare the two lists values, but as one is in read and one in write for each program, I can't understand what it is the problem.

user2239318
  • 2,578
  • 7
  • 28
  • 50

1 Answers1

1

if I add

A.join()
B.join()

the error disappear and the program run. Why this behavior?

user2239318
  • 2,578
  • 7
  • 28
  • 50