# -*- coding: utf-8 -*- from ops.mmysql import MysqlBase import logging from multiprocessing import Pool, cpu_count import datetime from mytask.tasks_1004 import * from mytask.tasks_base import * from mytask.tasks_1016 import * from mytask.tasks_2001 import * from config.config import * import sys log = logging.getLogger(__name__) def run_tasks(): args = event_list pool = Pool(processes=cpu_count()) pool.map(simple_work, args) pool.close() pool.join() class CollectGameData(): def __init__(self, times): self.times = times def workflow(self, line): kwargs = {} kwargs['gameid'], kwargs['channelid'], kwargs['event_type'] = line kwargs['date'] = self.times func = f"run_event_{kwargs['event_type']}(kwargs)" log.info(f"run {func} kwargs={kwargs}!") eval(func) def simple_work(line): cc = CollectGameData() cc.workflow(line) if __name__ == "__main__": # run_tasks() try: times = sys.argv[1] except: times = (datetime.date.today() - datetime.timedelta(days=1)).strftime('%Y-%m-%d') for line in event_list: cc = CollectGameData(times) cc.workflow(line)