github_archive_8.py 756 B

1234567891011121314151617181920
  1. def iterate_gists_to_archive(self, gists: List[Gist.Gist], operation: str) -> List[Optional[str]]:
  2. """Iterate over each gist and start a thread if it can be archived."""
  3. pool = ThreadPoolExecutor(self.threads)
  4. thread_list = []
  5. for gist in gists:
  6. gist_path = os.path.join(self.location, 'gists', gist.id)
  7. thread_list.append(
  8. pool.submit(
  9. self.archive_gist,
  10. gist=gist,
  11. gist_path=gist_path,
  12. operation=operation,
  13. )
  14. )
  15. wait(thread_list, return_when=ALL_COMPLETED)
  16. failed_gists = [gist.result() for gist in thread_list if gist.result()]
  17. return failed_gists