Created
November 21, 2022 09:20
-
-
Save AliRn76/0b48534c654170bd1f679a08beb6d859 to your computer and use it in GitHub Desktop.
Celery with Redis
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from pathlib import Path | |
from celery import Celery | |
from dotenv import dotenv_values | |
BASE_DIR = Path(__file__).resolve().parent.parent | |
env = dotenv_values(BASE_DIR / '.env') | |
REDIS_HOST = env['REDIS_HOST'] | |
REDIS_PORT = env['REDIS_PORT'] | |
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings') | |
celery_app = Celery('lms-exam', broker=f'redis://{REDIS_HOST}:{REDIS_PORT}') | |
celery_app.config_from_object('django.conf:settings', namespace='CELERY') | |
celery_app.autodiscover_tasks() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment