mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-07-15 01:55:21 +00:00
notification set up and celery configuration
This commit is contained in:
34
zod_bank/celery.py
Normal file
34
zod_bank/celery.py
Normal file
@ -0,0 +1,34 @@
|
||||
"""
|
||||
Celery Basic configuration
|
||||
"""
|
||||
|
||||
# python imports
|
||||
import os
|
||||
|
||||
# third party imports
|
||||
from celery import Celery
|
||||
from dotenv import load_dotenv
|
||||
from celery.schedules import crontab
|
||||
|
||||
# OR, the same with increased verbosity:
|
||||
load_dotenv(verbose=True)
|
||||
|
||||
env_path = os.path.join(os.path.abspath(os.path.join('.env', os.pardir)), '.env')
|
||||
|
||||
load_dotenv(dotenv_path=env_path)
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', os.getenv('SETTINGS'))
|
||||
|
||||
# celery app
|
||||
app = Celery()
|
||||
|
||||
app.config_from_object('django.conf:settings')
|
||||
|
||||
# Load task modules from all registered Django apps.
|
||||
app.autodiscover_tasks()
|
||||
|
||||
|
||||
@app.task(bind=True)
|
||||
def debug_task(self):
|
||||
""" celery debug task """
|
||||
print(f'Request: {self.request!r}')
|
Reference in New Issue
Block a user