Spaces:
Paused
Paused
File size: 1,123 Bytes
80bf15d 44a253c 80bf15d 44a253c 80bf15d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import asyncio
from collections import defaultdict
import logging
import traceback
logger = logging.getLogger("toolbox")
from toolbox.porter.common.params import Params
global_file_lock_dict = defaultdict(asyncio.Lock)
class BaseTask(Params):
def __init__(self,
flag: str,
check_interval: int,
):
super().__init__()
self.flag = flag
self.check_interval = check_interval
async def do_task(self):
raise NotImplementedError
async def start(self):
while True:
try:
await self.do_task()
logger.info(f"{self.flag}任务检测... 刷新间隔 {self.check_interval}s")
await asyncio.sleep(self.check_interval)
except Exception as error:
logger.error(f"{self.flag}任务检测出错\nerror type: {type(error)}, error text: {error}, traceback: {traceback.format_exc()}")
await asyncio.sleep(self.check_interval)
continue
if __name__ == "__main__":
pass
|