|  | @@ -6,13 +6,16 @@ import asyncio
 | 
	
		
			
				|  |  |  import datetime
 | 
	
		
			
				|  |  |  import traceback
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +from concurrent.futures import ThreadPoolExecutor, as_completed
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  from tasks.history_task import historyContentIdTask
 | 
	
		
			
				|  |  |  from applications.db import AsyncMySQLClient
 | 
	
		
			
				|  |  |  from applications.log import logging
 | 
	
		
			
				|  |  |  from applications.feishu import bot
 | 
	
		
			
				|  |  | +from applications.config.const import HistoryContentIdTaskConst
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -async def main():
 | 
	
		
			
				|  |  | +async def main(publish_flag):
 | 
	
		
			
				|  |  |      """
 | 
	
		
			
				|  |  |      main job
 | 
	
		
			
				|  |  |      :return:
 | 
	
	
		
			
				|  | @@ -58,16 +61,39 @@ async def main():
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          )
 | 
	
		
			
				|  |  |          return
 | 
	
		
			
				|  |  | -    await history_content_id_task.deal()
 | 
	
		
			
				|  |  | +    await history_content_id_task.deal(publish_flag)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -if __name__ == '__main__':
 | 
	
		
			
				|  |  | +def run_thread(publish_flag, sleep_seconds):
 | 
	
		
			
				|  |  | +    """
 | 
	
		
			
				|  |  | +    执行进程
 | 
	
		
			
				|  |  | +    """
 | 
	
		
			
				|  |  |      while True:
 | 
	
		
			
				|  |  | -        asyncio.run(main())
 | 
	
		
			
				|  |  | +        loop = asyncio.new_event_loop()
 | 
	
		
			
				|  |  | +        asyncio.set_event_loop(loop)
 | 
	
		
			
				|  |  | +        loop.run_until_complete(main(publish_flag=publish_flag))
 | 
	
		
			
				|  |  | +        loop.close()
 | 
	
		
			
				|  |  |          now_str = datetime.datetime.now().__str__()
 | 
	
		
			
				|  |  | -        print("{}    请求执行完成, 等待60s".format(now_str))
 | 
	
		
			
				|  |  |          logging(
 | 
	
		
			
				|  |  |              code="history0004",
 | 
	
		
			
				|  |  | -            info="History task finished"
 | 
	
		
			
				|  |  | +            info="History task finished",
 | 
	
		
			
				|  |  | +            alg="run_thread2"
 | 
	
		
			
				|  |  |          )
 | 
	
		
			
				|  |  | -        time.sleep(60)
 | 
	
		
			
				|  |  | +        print("{}    请求执行完成, 等待{}s".format(now_str, sleep_seconds))
 | 
	
		
			
				|  |  | +        time.sleep(sleep_seconds)
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +if __name__ == '__main__':
 | 
	
		
			
				|  |  | +    const = HistoryContentIdTaskConst()
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    with ThreadPoolExecutor(max_workers=2) as executor:
 | 
	
		
			
				|  |  | +        futures = [
 | 
	
		
			
				|  |  | +            executor.submit(run_thread, const.NEED_PUBLISH, const.NEED_PUBLISH_WAIT_TIME),
 | 
	
		
			
				|  |  | +            executor.submit(run_thread, const.DO_NOT_NEED_PUBLISH, const.DO_NOT_NEED_PUBLISH_WAIT_TIME)
 | 
	
		
			
				|  |  | +        ]
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        try:
 | 
	
		
			
				|  |  | +            for future in as_completed(futures):
 | 
	
		
			
				|  |  | +                future.result()
 | 
	
		
			
				|  |  | +        except KeyboardInterrupt:
 | 
	
		
			
				|  |  | +            print("Stopping all threads...")
 |