This commit is contained in:
2024-07-01 06:01:50 +03:00
parent a6f7a9d65f
commit 386ee7e460
29 changed files with 727 additions and 296 deletions

2
background/__init__.py Normal file
View File

@@ -0,0 +1,2 @@
from .worker import celery
from .tasks import *

9
background/tasks.py Normal file
View File

@@ -0,0 +1,9 @@
import json
from background import celery
@celery.task(name='test')
def test_task():
with open('test.json', 'a') as tf:
tf.write(json.dumps({'ok': True}))

8
background/worker.py Normal file
View File

@@ -0,0 +1,8 @@
from celery import Celery
from backend.config import CELERY_RESULT_BACKEND, CELERY_BROKER_URL
celery = Celery(
__name__,
broker=CELERY_BROKER_URL,
backend=CELERY_RESULT_BACKEND
)