Skip to content

Instantly share code, notes, and snippets.

@nkrabben
Last active May 16, 2019 17:36
Show Gist options
  • Save nkrabben/e44390085825a564117760debb8d15af to your computer and use it in GitHub Desktop.
Save nkrabben/e44390085825a564117760debb8d15af to your computer and use it in GitHub Desktop.
Read from multiple hard drives simultaneously to fill up all 10G of bandwidth
import os
import subprocess
import multiprocessing
import timeit
def work(drive):
cmd = [
'snowball',
'cp',
drive,
's3://yadayadayada']
try:
subprocess.check_call(cmd)
except:
print("Didn't work for: {}", drive)
return
def main():
tic = timeit.default_timer()
#find path for each drive
drives = [os.path.join('/Volumes', x) for x in os.listdir('/Volumes') if x in ['Macintosh HD', 'Recovery']]
print(drives)
#spin up a process to process material on each drive
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