Created
March 7, 2020 12:53
-
-
Save martanto/a8ed887effb7f11da123eb639f87b632 to your computer and use it in GitHub Desktop.
Transfer file multithreading
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
import os | |
import shutil | |
from multiprocessing.dummy import Pool as ThreadPool | |
from tqdm import tqdm | |
df['image'] = df['_id'].apply(lambda x:x+".jpg") | |
path = df['image'].tolist() | |
def move_file(pth): | |
shutil.move("/content/netaporter_gb/"+pth, "/content/netaporter_gb_images/"+pth) | |
batch = 2048 | |
thread = 16 | |
for i in tqdm(range(0,len(path),batch)): | |
pool = ThreadPool(thread) | |
pool.map(move_file, path[i:i+batch]) | |
pool.close() | |
pool.join() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment