-
Notifications
You must be signed in to change notification settings - Fork 10
/
celery.py
28 lines (19 loc) · 659 Bytes
/
celery.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from __future__ import absolute_import, unicode_literals
from celery import Celery
from datetime import datetime, timedelta
import os
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'celery_demo.settings')
app = Celery('celery_demo')
app.config_from_object('django.conf:settings', namespace='CELERY')
app.conf.beat_schedule = {
'add-every-5-seconds': {
'task': 'notifications.tasks.send_email',
'schedule': 1.0,
'args': ('[email protected]','This is sample message.')
}
}
app.conf.timezone = 'UTC'
app.autodiscover_tasks()
@app.task(bind=True)
def debug_task(self):
print('Request: {0!r}'.format(self.request))