|
|
@@ -11,7 +11,7 @@ from utils.drission_page import ChromeOptions
|
|
|
from utils.file import read_file,save_to_file
|
|
|
from utils.logu import get_logger
|
|
|
logger = get_logger('browser')
|
|
|
-
|
|
|
+asyncio.set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy())
|
|
|
async def async_run_extractions(crawler:Crawler, html_content):
|
|
|
"""异步运行提取逻辑"""
|
|
|
product_info, result_table = await asyncio.gather(
|
|
|
@@ -68,12 +68,14 @@ async def async_process_mhtml(mhtml_path: str):
|
|
|
def extra_result(self, mhtml_path: str):
|
|
|
"""异步Celery任务"""
|
|
|
try:
|
|
|
+ loop = asyncio.get_event_loop()
|
|
|
logger.info(f"异步任务启动: {mhtml_path}")
|
|
|
- res = asyncio.run(async_process_mhtml(mhtml_path))
|
|
|
+ res = loop.run_until_complete(async_process_mhtml(mhtml_path))
|
|
|
+ # res = asyncio.run(async_process_mhtml(mhtml_path))
|
|
|
logger.info(f"异步任务完成: {res}")
|
|
|
return res
|
|
|
except Exception as e:
|
|
|
- logger.error(f"任务重试中: {str(e)}")
|
|
|
+ logger.exception(f"任务重试中: {str(e)}")
|
|
|
self.retry(exc=e, countdown=60)
|
|
|
|
|
|
def main():
|