""" @author: luojunhui """ import time import asyncio import datetime import traceback from tasks.history_task import historyContentIdTask from applications.db import AsyncMySQLClient from applications.log import logging from applications.feishu import bot async def main(): """ main job :return: """ async_mysql_pool = AsyncMySQLClient() try: await async_mysql_pool.init_pool() logging( code="history0001", info="Init MySQL pool successfully", alg="historyContentIdTask", function="main" ) except Exception as e: logging( code="history0002", info="Init MySQL pool failed", alg="historyContentIdTask", function="main", data={ "error": str(e), "traceback": traceback.format_exc() } ) bot( title="historyContentIdTask INIT MYSQL FAILS", detail={ "error": str(e), "traceback": traceback.format_exc() } ) try: history_content_id_task = historyContentIdTask(async_mysql_pool) except Exception as e: logging( code="history0003", info="Init historyContentIdTask failed", alg="historyContentIdTask", function="main", data={ "error": str(e), "traceback": traceback.format_exc() } ) return await history_content_id_task.deal() if __name__ == '__main__': while True: asyncio.run(main()) now_str = datetime.datetime.now().__str__() print("{} 请求执行完成, 等待60s".format(now_str)) logging( code="history0004", info="History task finished" ) time.sleep(60)