HEX
Server: nginx/1.29.3
System: Linux mail.sarafai.ru 6.1.0-40-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.153-1 (2025-09-20) x86_64
User: www-data (33)
PHP: 7.4.33
Disabled: dl,exec,passthru,shell_exec,system,proc_open,popen,parse_ini_file,show_source
Upload Files
File: //proc/682/cwd/project/celery_app.py
import os
from celery import Celery
from django.conf import settings

# $ pip install celery

# Don't forget install RabbitMQ:
# $ sudo apt-get install rabbitmq-server

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings')

# on Windows / 2025.01.23
os.environ.setdefault('FORKED_BY_MULTIPROCESSING', '1')


# app = Celery('project',
#              broker='pyamqp://',
#              backend='rpc://',
#              include=['project.celery_tasks'])

app = Celery('project')

# app.conf.update(
#     result_expires=3600
# )

# Using a string here means the worker doesn't have to serialize
# the configuration object to child processes.
# - namespace='CELERY' means all celery-related configuration keys
#   should have a `CELERY_` prefix.
# app.config_from_object('django.conf:settings')
# app.config_from_object('django.conf:settings', namespace='CELERY')
app.config_from_object(settings, namespace='CELERY')

# Load task modules from all registered Django apps.
# app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)


# @app.task(bind=True)
# def debug_task(self):
#     print(f'Request: {self.request!r}')


if __name__ == '__main__':
    app.start()


# Run Celery instance as
# $ celery -A project worker -l INFO
#