Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiprocessing can only join a started process [closed]

I have the following Python code

jobs = []
p = Process(target=self.verify_process, args=(vm_ha1, creds, run_cmd_ha1, ip_ha1))
jobs.append(p)
p.start()
p = Process(target=self.verify_process, args=(vm_ha2, creds, run_cmd_ha2, ip_ha2))
jobs.append(p)
p.start
p = Process(target=self.verify_process, args=(vm_client, creds, run_cmd_client, ip_client))
jobs.append(p)
p.start
for p in jobs:
    p.join()

The target is a small def checking if a process on a VM has finished, and will print the exit code.

When this is running, I get an error after the first process is finished, and writing its output

  File "/usr/lib/python2.7/multiprocessing/process.py", line 144, in join
    assert self._popen is not None, 'can only join a started process'
AssertionError: can only join a started process

When I was looking around for this, I found a few mentions of this. And most of them were because they were all using p.run() and should use p.start().

But I'm using p.start() already.

This is the first time I'm tying out Multiprocessing, so it is possible I'm using it incorrectly.

From what I can see all 3 processes should be started.

like image 328
derchris Avatar asked Sep 12 '26 09:09

derchris


1 Answers

You forgot the parenthesis for the second and third p.start. It should be:

p.start()
like image 152
Assem Avatar answered Sep 13 '26 21:09

Assem



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!