Skip to content

Instantly share code, notes, and snippets.

@thomascate
Created July 3, 2014 16:03
Show Gist options
  • Save thomascate/c48db89a142d0cf6ccbc to your computer and use it in GitHub Desktop.
Save thomascate/c48db89a142d0cf6ccbc to your computer and use it in GitHub Desktop.
threads = 6
for fileName in fileNames:
queue.put(fileName)
for i in range(threads):
t = threading.Thread(target=get_backup_list, args=(queue,dbCreds,arguments.verbose,arguments.vault))
activeThreads.append(t)
t.start()
for activeThread in activeThreads:
activeThread.join()
def get_backup_list(queue,dbCreds,verbosity,vault):
backupFiles = []
while True:
if queue.empty() == True:
return
fileName = queue.get()
try:
fileInfo = lookup_file_by_path(fileName,dbCreds,vault)
if not fileInfo:
start = time.time()
attributes = get_attributes(fileName,verbosity)
end = time.time() - start
if verbosity: print("finished in ") + str(end) + (" seconds")
insert_file(attributes,dbCreds,vault)
fileInfo = lookup_file_by_path(fileName,dbCreds,vault)
except Exception, e:
print("error on " + fileName + " " + str(e))
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment