H
H
Hello World2019-06-28 16:40:55
Python
Hello World, 2019-06-28 16:40:55

Why is terminating a process not working?

I am using multiprocessing .
In a simplified form, the code looks like this:

class MainProcess(mp.Process):
    def run(self):
        self.proc1 = mp.Process(target=function1, args=(....))
        self.proc2 = mp.Process(target=function2, args=(....))
        self.proc3 = mp.Process(target=function3, args=(....))
        self.proc4 = mp.Process(target=function4, args=(....))

    def terminate(self):
        self.proc1.terminate()
        self.proc2.terminate()
        self.proc3.terminate()
        self.proc4.terminate()

But the processes are not terminated, and the same thing is written to the database n times. Why is this happening?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Kitaev, 2019-06-28
@deliro

No need to end processes. They need to know for themselves when they're done.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question