from multiprocessing import Process, Queue
import os
import time
def copy_func(files, q):
for f in files:
print("copying:",f)
time.sleep(3)
q.put(f)
def process_func(maxnum, q):
index = 0
while index < maxnum:
if not q.empty():
f = q.get()
print("processing:",f)
time.sleep(5)
index += 1
time.sleep(1)
if __name__ == '__main__':
q = Queue()
copy = Process(target = copy_func, args=(range(10), q))
pros = Process(target = process_func, args=(10, q))
copy.start()
pros.start()
copy.join()
print("finish copy")
pros.join()
print("finish proc")