| 1 |
import os |
| 2 |
|
| 3 |
from celery import Celery |
| 4 |
|
| 5 |
# Set the default Django settings module for the 'celery' program. |
| 6 |
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'proj.settings') |
| 7 |
|
| 8 |
app = Celery('proj') |
| 9 |
|
| 10 |
# Using a string here means the worker doesn't have to serialize |
| 11 |
# the configuration object to child processes. |
| 12 |
# - namespace='CELERY' means all celery-related configuration keys |
| 13 |
# should have a `CELERY_` prefix. |
| 14 |
app.config_from_object('django.conf:settings', namespace='CELERY') |
| 15 |
|
| 16 |
# Load task modules from all registered Django apps. |
| 17 |
app.autodiscover_tasks() |
| 18 |
|
| 19 |
|
| 20 |
@app.task(bind=True, ignore_result=True) |
| 21 |
def debug_task(self): |
| 22 |
print(f'Request: {self.request!r}') |