Skip to content

Instantly share code, notes, and snippets.

@tuttelikz
Last active August 26, 2020 18:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuttelikz/48b218f290c09b1ca73f19dfae4bea5a to your computer and use it in GitHub Desktop.
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.
"""
* 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