| Server IP : 82.148.16.210 / Your IP : 216.73.216.19 Web Server : nginx/1.29.5 System : Linux mail.sarafai.ru 6.1.0-43-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.162-1 (2026-02-08) x86_64 User : root ( 0) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /proc/529/cwd/project/ |
Upload File : |
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
#