in aliyun/log/es_migration/migration_task.py [0:0]
def run(self, shutdown_flag):
# already finished
if self._ckpt.status == Checkpoint.finished:
self._logger.info('Already finished. Ignore it.')
return Checkpoint.finished
self._logger.info('Migration task starts', extra=self._ckpt.content)
try:
self._run(shutdown_flag)
except NotFoundError:
self._ckpt.update(status=Checkpoint.dropped)
self._logger.info(
'ES index dropped',
extra={'traceback': traceback.format_exc()},
)
except KeyboardInterrupt:
self._logger.info('Migration interrupted')
self._status = Checkpoint.interrupted
except BaseException:
self._logger.error(
'Exception',
extra={'traceback': traceback.format_exc()},
)
self._status = Checkpoint.failed
finally:
self._ckpt.update(
status=self._status,
count=self._cnt,
_id=None if self._last is None else self._last.get('_id'),
scroll_id=self._es_scroll_id,
)
self._logger.info('Migration task exits', extra=self._ckpt.content)
return self._ckpt.status