-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
26 lines (20 loc) · 773 Bytes
/
app.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
from datetime import timedelta
from celery import Celery
from celery.task import periodic_task
"""
Intialize celery worker with redis as message broker
message broker is used here to persist informations \
for the worker such any status updates,running times,results etc
"""
app = Celery('tasks', broker='redis://redis:6379/0')
"""
a celery periodic function.
This will executed as per the scheduled times
eg: run_every=timedelta(seconds=5) will make it run every min
ref: http://docs.celeryproject.org/en/latest/reference/celery.schedules.html
ref: http://docs.celeryproject.org/en/latest/userguide/periodic-tasks.html
"""
@periodic_task(run_every=timedelta(seconds=5))
def sample_function():
# add your periodic code here
return ' i running periodic task '