You want to change the code in mod_scanProfiles.main to block until all its threads are complete.
Assuming you call subprocess.Popen in this function, simply do:
# in mod_scanPfiles.main: p = subprocess.Popen(...) p.wait()
If you do not expect your threads to finish, you will also want to call Thread.join ( docs ) to wait for them to complete. For instance:
# assuming you have a list of thread objects somewhere threads = [MyThread(), ...] for thread in threads: thread.start() for thread in threads: thread.join()
source share