-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtask_queue.py
More file actions
28 lines (22 loc) · 801 Bytes
/
task_queue.py
File metadata and controls
28 lines (22 loc) · 801 Bytes
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
import os
from dotenv import load_dotenv, find_dotenv
from celery import Celery
load_dotenv(dotenv_path=find_dotenv(), verbose=True)
app = Celery('spotify')
CELERY_BROKER_URL = os.getenv('REDIS_URL')
app.conf.update({
'BROKER_URL': CELERY_BROKER_URL,
# Recommended settings. See: https://www.cloudamqp.com/docs/celery.html
'BROKER_POOL_LIMIT': None,
'BROKER_HEARTBEAT': None,
'BROKER_CONNECTION_TIMEOUT': 30,
'CELERY_RESULT_BACKEND': CELERY_BROKER_URL,
'CELERY_SEND_EVENTS': False,
'CELERY_EVENT_QUEUE_EXPIRES': 60,
})
app.config_from_object('django.conf:settings', namespace='CELERY')
# Load task modules from all registered Django app configs.
app.autodiscover_tasks()
@app.task(bind=True)
def debug_task(self):
print('Request: {0!r}'.format(self.request))