clearml/trains/utilities/pigar/extractor/extractor.py

37 lines
822 B
Python
Raw Normal View History

2020-03-01 15:12:28 +00:00
# -*- coding: utf-8 -*-
from __future__ import print_function, division, absolute_import
import multiprocessing
class BaseExtractor(object):
def __init__(self, names, max_workers=None):
self._names = names
self._max_workers = max_workers or (multiprocessing.cpu_count() * 4)
def run(self, job):
try:
self.extract(job)
self.wait_complete()
except KeyboardInterrupt:
print('** Shutting down ...')
self.shutdown()
else:
print('^.^ Extracting all packages done!')
finally:
self.final()
def extract(self, job):
raise NotImplemented
def wait_complete(self):
raise NotImplemented
def shutdown(self):
raise NotImplemented
def final(self):
pass