Reputation: 23
I've been having these issues on my celery beat and worker where my celery beat creates task, but celery worker does not receive it. I am using elasticmq as the broker
My celery beat logs
It does not pick up the tasks from celery beat, here is the snippet of the task
app = Celery("app")
logger = get_task_logger(__name__)
CELERY_CONFIG = {
"CELERY_TASK_SERIALIZER": "json",
"CELERY_ACCEPT_CONTENT": ["json"],
"CELERY_RESULT_SERIALIZER": "json",
"CELERY_RESULT_BACKEND": None,
"CELERY_ENABLE_UTC": True,
"CELERY_ENABLE_REMOTE_CONTROL": False,
}
BROKER_URL = "sqs://user:password@sqs:9324/"
CELERY_CONFIG.update(
{
"BROKER_URL": BROKER_URL,
"BROKER_TRANSPORT": "sqs",
"BROKER_TRANSPORT_OPTIONS": {
"region": "us-west-2",
"use_ssl": False,
"visibility_timeout": 3600,
"polling_interval": 60,
},
}
)
app.conf.update(**CELERY_CONFIG)
app.config_from_object("django.conf:settings", namespace="CELERY")
and here is the task,
@celery.app.task()
def beat_task() -> None:
logger.info("Starting beat task...")
time.sleep(2)
logger.info("Done beat task.")
CELERY_BEAT_SCHEDULE = {
"beat_task": {
"task": "app.tasks.beat_task",
"schedule": timedelta(seconds=10),
},
}
I am not getting the logger info print result on worker
Tried connecting celery worker and beat, did not work
Here are some screenshots
[![Screenshot of the beat sending queues][2]][2]
[![Nothing received from the worker][3]][3] Screenshot of the celery worker
Screenshot of the beat sending queues [2]: https://i.sstatic.net/YpjDn.png Nothing received from the worker [3]: https://i.sstatic.net/skRL8.png
Upvotes: 0
Views: 367
Reputation: 75
the celery.app
object is not defined here.the Celery object is here initialized with the name app
and not celery.app
.
so change the decorator to @app.task()
.
app = Celery("app")
logger = get_task_logger(__name__).....
@app.task()
def beat_task().....
update any other references from celery.app
in your code to app
Upvotes: 0