def another_dummy_celery_task(local_celery_app: Celery, celery_worker: Worker) -> PromiseProxy: @local_celery_app.task() def _another_dummy() -> None: pass # NOTE: Avoiding the following reload causes the worker not to know about the just registered # task and raise UnrecoverableError celery_worker.reload() return _another_dummy
def handle(self, *args, **options): celery_app.config_from_object('django.conf:settings', namespace='CELERY') # Load task modules from all registered Django app configs. celery_app.autodiscover_tasks() celery_worker = CeleryWorker( hostname="localhost", app=celery_app, ) celery_worker.start()
def handle(self, *args, **options): celery_app.config_from_object('django.conf:settings', namespace='CELERY') # Load task modules from all registered Django app configs. celery_app.autodiscover_tasks() celery_worker = CeleryWorker(hostname="localhost", app=celery_app, beat=True, quiet=True, concurrency=1) # Set pidfile if it the corresponding argument has been provided if options['pidfile']: celery_worker.pidfile = options['pidfile'] celery_worker.start()
def serve(): update_celery_config(app) server_mode = app.conf.get('mode', SERVER_MODE_ENUM.WORKER.value) if server_mode == SERVER_MODE_ENUM.BEAT.value: Beat(app=app, loglevel='DEBUG').run() elif server_mode == SERVER_MODE_ENUM.SPACEONE_BEAT.value: app.conf.update(beat_scheduler=DEFAULT_SPACEONE_BEAT) Beat(app=app, loglevel='DEBUG').run() else: Worker(app=app).start()
def run(self, *args, **kwargs): from celery.apps.worker import Worker kwargs["defaults"] = self.defaults return Worker(**kwargs).run()