Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 14301

Execute third function after the completion of first two functions run concurrently

$
0
0

I have the following code:

class RepeatTimer(Timer):"""    Extending the threading.Timer class to execute functions at fixed intervals."""    def run(self):        while not self.finished.wait(self.interval):            self.function(*self.args, **self.kwargs)def parallel_process(mp, arguments, cb_fn):    main_process = multiprocessing.Process(target=mp, args=[arguments, cb_fn])    side_process = RepeatTimer(30, generate_info)    final_process = multiprocessing.Process(target=create_final)    main_process.start()    side_process.start()    main_process.join()    side_process.cancel()    final_process.start()    final_process.join()

mp, generate_info, and create_final are my functions being used. I wish to execute mp and generate_info concurrently and then execute create_final after their completion.

mp and generate_info run concurrently if I don't use the create_final function, but after I use the function, it also starts running while the other two are running. I read about it and got to know join() method will only block the main process, and not other multiprocessing functions.

What can I do to get my desired output? Even using concurrent.futures also throws the same error.


Viewing all articles
Browse latest Browse all 14301

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>