From 27172c2c2b0a8b21b660dddc6b7556dfa7a3e17a Mon Sep 17 00:00:00 2001 From: H Vs Date: Tue, 8 Apr 2025 16:18:35 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- celery_app.py | 2 +- run.py | 2 +- tasks.py | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/celery_app.py b/celery_app.py index 694a466..324974e 100644 --- a/celery_app.py +++ b/celery_app.py @@ -36,7 +36,7 @@ elif environment == 'test': scheduled_task_add_contacts_from_chatrooms_interval = 60*11 else: scheduled_task_sync_wx_info_interval = 6000 - scheduled_task_add_contacts_from_chatrooms_interval=60 + scheduled_task_add_contacts_from_chatrooms_interval=6 # 定义定时任务列表 (任务 ID, 任务名称, 执行间隔秒, 任务参数) diff --git a/run.py b/run.py index 5a43615..4512bb2 100644 --- a/run.py +++ b/run.py @@ -39,7 +39,7 @@ if __name__ == "__main__": celery_beat_process = start_celery_beat() # 等待子进程完成 - #fastapi_process.wait() + fastapi_process.wait() celery_worker_process.wait() celery_beat_process.wait() diff --git a/tasks.py b/tasks.py index d753677..8aef282 100644 --- a/tasks.py +++ b/tasks.py @@ -15,8 +15,11 @@ import asyncio,random from model.models import AddGroupContactsHistory + + @celery_app.task(name='tasks.add_task', bind=True, acks_late=True) def add_task(self, x, y): + time.sleep(5) # 模拟长时间计算 logger.info('add') return x + y