|  | @@ -16,7 +16,7 @@ from applications.feishu import bot
 | 
											
												
													
														|  |  from applications.config.const import HistoryContentIdTaskConst
 |  |  from applications.config.const import HistoryContentIdTaskConst
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -async def main(publish_flag):
 |  | 
 | 
											
												
													
														|  | 
 |  | +async def do_job(publish_flag):
 | 
											
												
													
														|  |      """
 |  |      """
 | 
											
												
													
														|  |      main job
 |  |      main job
 | 
											
												
													
														|  |      :return:
 |  |      :return:
 | 
											
										
											
												
													
														|  | @@ -72,7 +72,7 @@ def run_thread(publish_flag, sleep_seconds, stop_flag):
 | 
											
												
													
														|  |      while not stop_flag.is_set():
 |  |      while not stop_flag.is_set():
 | 
											
												
													
														|  |          loop = asyncio.new_event_loop()
 |  |          loop = asyncio.new_event_loop()
 | 
											
												
													
														|  |          asyncio.set_event_loop(loop)
 |  |          asyncio.set_event_loop(loop)
 | 
											
												
													
														|  | -        loop.run_until_complete(main(publish_flag=publish_flag))
 |  | 
 | 
											
												
													
														|  | 
 |  | +        loop.run_until_complete(do_job(publish_flag=publish_flag))
 | 
											
												
													
														|  |          loop.close()
 |  |          loop.close()
 | 
											
												
													
														|  |          now_str = datetime.datetime.now().__str__()
 |  |          now_str = datetime.datetime.now().__str__()
 | 
											
												
													
														|  |          logging(
 |  |          logging(
 | 
											
										
											
												
													
														|  | @@ -84,20 +84,26 @@ def run_thread(publish_flag, sleep_seconds, stop_flag):
 | 
											
												
													
														|  |          time.sleep(sleep_seconds)
 |  |          time.sleep(sleep_seconds)
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -if __name__ == '__main__':
 |  | 
 | 
											
												
													
														|  | 
 |  | +def main():
 | 
											
												
													
														|  | 
 |  | +    """
 | 
											
												
													
														|  | 
 |  | +    main function
 | 
											
												
													
														|  | 
 |  | +    """
 | 
											
												
													
														|  |      const = HistoryContentIdTaskConst()
 |  |      const = HistoryContentIdTaskConst()
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  |      stop_event = threading.Event()
 |  |      stop_event = threading.Event()
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |      # 启动两个线程,分别执行两个函数
 |  |      # 启动两个线程,分别执行两个函数
 | 
											
												
													
														|  |      with ThreadPoolExecutor(max_workers=2) as executor:
 |  |      with ThreadPoolExecutor(max_workers=2) as executor:
 | 
											
												
													
														|  |          futures = [
 |  |          futures = [
 | 
											
												
													
														|  |              executor.submit(run_thread, const.NEED_PUBLISH, const.NEED_PUBLISH_WAIT_TIME, stop_event),
 |  |              executor.submit(run_thread, const.NEED_PUBLISH, const.NEED_PUBLISH_WAIT_TIME, stop_event),
 | 
											
												
													
														|  |              executor.submit(run_thread, const.DO_NOT_NEED_PUBLISH, const.DO_NOT_NEED_PUBLISH_WAIT_TIME, stop_event)
 |  |              executor.submit(run_thread, const.DO_NOT_NEED_PUBLISH, const.DO_NOT_NEED_PUBLISH_WAIT_TIME, stop_event)
 | 
											
												
													
														|  |          ]
 |  |          ]
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  |          try:
 |  |          try:
 | 
											
												
													
														|  |              for future in as_completed(futures):
 |  |              for future in as_completed(futures):
 | 
											
												
													
														|  |                  future.result()
 |  |                  future.result()
 | 
											
												
													
														|  |          except KeyboardInterrupt:
 |  |          except KeyboardInterrupt:
 | 
											
												
													
														|  |              print("Stopping all threads...")
 |  |              print("Stopping all threads...")
 | 
											
												
													
														|  | -            stop_event.set()
 |  | 
 | 
											
												
													
														|  | 
 |  | +            stop_event.set()
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +if __name__ == '__main__':
 | 
											
												
													
														|  | 
 |  | +    main()
 |