def run(self):
try:
thread_count = self.threads()
self._pool = Pool(processes=thread_count)
logging.info("Archiving backup directories with pool of %i thread(s)" % thread_count)
except Exception, e:
logging.fatal("Could not start pool! Error: %s" % e)
raise Error(e)
if os.path.isdir(self.backup_dir):
try:
self.running = True
for backup_dir in os.listdir(self.backup_dir):
subdir_name = os.path.join(self.backup_dir, backup_dir)
if not os.path.isdir(os.path.join(subdir_name, "dump")):
continue
output_file = "%s.tar" % subdir_name
if self.do_gzip():
output_file = "%s.tgz" % subdir_name
self._pool.apply_async(TarThread(subdir_name, output_file, self.compression(), self.verbose, self.binary).run, callback=self.done)
self._pooled.append(subdir_name)
except Exception, e:
self._pool.terminate()
logging.fatal("Could not create tar archiving thread! Error: %s" % e)
raise Error(e)
finally:
self.wait()
self.completed = True
评论列表
文章目录