123
This commit is contained in:
2
background/__init__.py
Normal file
2
background/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from .worker import celery
|
||||
from .tasks import *
|
||||
9
background/tasks.py
Normal file
9
background/tasks.py
Normal 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
8
background/worker.py
Normal 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
|
||||
)
|
||||
Reference in New Issue
Block a user