Created
May 9, 2019 13:59
-
-
Save nkrabben/7bab2390d365980044b2b1ff0b844e7c to your computer and use it in GitHub Desktop.
Multiprocess naive snowball cp
This file contains hidden or 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 subprocess | |
import multiprocessing | |
import timeit | |
def work(drive): | |
cmd = [ | |
'snowball', | |
'cp', | |
os.path.join(drive, '*/*/data/{E,S}*/*'), | |
's3://yadayadayada'] | |
try: | |
subprocess.check_call(cmd) | |
except: | |
print("Didn't work for: {}", drive) | |
return | |
def main(): | |
tic = timeit.default_timer() | |
drives = [os.path.join('/Volumes', x) for x in os.listdir('/Volumes') if x != 'Macintosh HD'] | |
print(drives) | |
pool = multiprocessing.Pool(processes=len(drives)) | |
r = pool.map_async(work, drives) | |
r.wait() | |
toc = timeit.default_timer() | |
print("It took this long: {}".format(tic-toc)) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment