I"m trying to copy files in python , it'll take long time in sequential approach so I wanted to do it in multiple threads. Below is my code to copy files in sequential
for file in files:
shutil.copy(file,destination_path)
this took around 1.2 sec to complete I tried to implement multithreading as below
import multiprocessing
copy_instance(src,dest):
shutil.copy(src,dest)
for file in files:
p1 = multiprocessing.process(target=copy_instance,args=(file,destination_path)
p1.start()
this took 168.8 sec to complete
Doing it in multiprocessing taking way more time then sequential approach , what am I doing wrong? how can I correctly implement multithreading to speed up my copying process? any help or suggestion on this will be very helpful, thanks