Last active
August 26, 2020 18:18
-
-
Save tuttelikz/48b218f290c09b1ca73f19dfae4bea5a to your computer and use it in GitHub Desktop.
Example to use multiprocessing.Pool with map. Copies images from source folder to destination.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
* MultiprocessingExample.py * | |
Example to use multiprocessing.Pool with map. | |
Copies images from source folder to destination. | |
# Author: San Askaruly | @tuttelikz | |
""" | |
from os import listdir | |
from multiprocessing import Pool | |
from shutil import copyfile | |
src_path = '' # define source path here | |
dst_path = '' # define destination path there | |
src_flist = listdir(src_path) | |
def f(x): | |
new_name = ImgInfo(fpath).getDate() + '.jpg' | |
copyfile(join(src_path, x), join(dst_path, new_name)) | |
print(dpath) | |
if __name__ == '__main__': | |
print("start") | |
with Pool(70) as p: | |
p.map(f, src_flist) | |
p.join() | |
print("finish") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment