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