Skip to content

Commit 439c194

Browse files
committed
add test task celery
1 parent b6931a4 commit 439c194

3 files changed

Lines changed: 16 additions & 2 deletions

File tree

api_v1/users/tasks.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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'

app_includes/logs_errors.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111

1212
def register_errors(app: FastAPI) -> None:
13+
"""
14+
Крючек для логирования различных исключений
15+
"""
1316
@app.exception_handler(ValidationError)
1417
async def validation_error_handler(
1518
request: Request,

config/celery/connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class 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

4242
app = Celery(__name__)
4343
app.conf.broker_url = settings.rabbit.broker_url
44-
app.autodiscover_tasks(packages=[])
44+
app.autodiscover_tasks(packages=['api_v1.users'])

0 commit comments

Comments
 (0)