من يتكرم و يشرح لي هذيهن الكودين يا ريت شرط وافي
1/
#!/usr/bin/env python3
from multiprocessing import Pool
def run(task):
# Do something with task here
print("Handling {}".format(task))
if __name__ == "__main__":
tasks = ['task1', 'task2', 'task3']
# Create a pool of specific number of CPUs
p = Pool(len(tasks))
# Start each task within the pool
p.map(run, tasks)
2/
#!/usr/bin/env python3
import subprocess
from multiprocessing import Pool
import os
src = "/data/prod/"
dest = "/data/prod_backup/"
def run(dirname):
subprocess.call(["rsync", "-arq", src + dirname, dest + dirname])
if __name__ == "__main__" :
for root, dirs, files in os.walk(src):
if len(dirs) > 0 : break
p = Pool(len(dirs))
p.map(run, dirs)