File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ from config import celery_app
2+ import asyncio
3+
4+
5+ @celery_app .task
6+ async def time_sleep_task ():
7+ """
8+ Тестовая задача для Celery
9+ """
10+ asyncio .sleep (2.0 )
11+ return 'Task is done'
Original file line number Diff line number Diff line change 1010
1111
1212def register_errors (app : FastAPI ) -> None :
13+ """
14+ Крючек для логирования различных исключений
15+ """
1316 @app .exception_handler (ValidationError )
1417 async def validation_error_handler (
1518 request : Request ,
Original file line number Diff line number Diff line change 99
1010class Celery (celery .Celery ):
1111 """
12- Инициализация Celery
12+ Инициализация асинхронного Celery
1313 """
1414
1515 def __init__ (self , * args , ** kwargs ) -> None :
@@ -41,4 +41,4 @@ def wrapper(*args,
4141
4242app = Celery (__name__ )
4343app .conf .broker_url = settings .rabbit .broker_url
44- app .autodiscover_tasks (packages = [])
44+ app .autodiscover_tasks (packages = ['api_v1.users' ])
You can’t perform that action at this time.
0 commit comments