Skip to content

Commit a8da570

Browse files
committed
Add example task 🍣
1 parent 8ebfd51 commit a8da570

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

project/project/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from __future__ import absolute_import
2+
3+
from .celery import app as celery_app
4+
5+
__all__ = ['celery_app']

project/project/celery.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from __future__ import absolute_import
2+
import os
3+
from celery import Celery, shared_task
4+
5+
from django.conf import settings
6+
7+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings')
8+
app = Celery('project')
9+
10+
app.config_from_object('django.conf:settings')
11+
app.autodiscover_tasks()
12+
13+
14+
@app.task(bind=True)
15+
def debug_task(self):
16+
print('Request: {0!r}'.format(self.request))
17+
18+
from celery import shared_task
19+
20+
@shared_task()
21+
def example_task(first_arg, second_arg):
22+
print('Hello')

project/project/tasks.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)