celery-task

Can we get the signature or arguments of a celery task on `task_prerun`

Can we get the signature or arguments of a celery task on `task_prerun` Question: My plan is to log all celery task requests with the arguments they receive s I’m using the following @task_prerun.connect() def log_celery_args(task, **kwargs): logger.info(f"{task.name} {kwargs[‘kwargs’]}", extra=kwargs[‘kwargs’]) The problem is this solution doesn’t work when the functions don’t use named parameters. I …

Total answers: 1

Celery crontab to schedule 1 of the month and quarterly in year

Celery crontab to schedule 1 of the month and quarterly in year Question: I have a celery task which executes quarterly on 1 of the month how can my month_of_year can be written { ‘task’: ‘mytask’, ‘schedule’: crontab(day_of_month=’1′, month_of_year=”) }, Asked By: jimmy || Source Answers: Use month_of_year=’*/3′ to run every quarter month { ‘task’: …

Total answers: 1

After Changing Python Version 3.6 to 3.10 I got cannot import name 'Callable' from 'collections'

After Changing Python Version 3.6 to 3.10 I got cannot import name 'Callable' from 'collections' Question: File "C:UsersCodertjayPycharmProjectsTeems_App_Kidteems_app_kid__init__.py", line 5, in <module> from .celery import app as celery_app File "C:UsersCodertjayPycharmProjectsTeems_App_Kidteems_app_kidcelery.py", line 3, in <module> from celery import Celery File "C:UsersCodertjayPycharmProjectsbrownieTeems_App_Kidlibsite-packagesceleryfive.py", line 306, in __getattr__ module = __import__(self._object_origins[name], None, None, [name]) File "C:UsersCodertjayPycharmProjectsbrownieTeems_App_Kidlibsite-packagesceleryapp__init__.py", line 14, in …

Total answers: 3

KeyError Received unregistered task of type '' on celery while task is registered

KeyError Received unregistered task of type '' on celery while task is registered Question: I’m a bit new in celery configs. I have a task named myapp.tasks.my_task for example. I can see myapp.tasks.my_task in registered tasks of celery when I use celery inspect registered. doesn’t it mean that the task is successfully registered? why it …

Total answers: 4

kombu.exceptions.EncodeError: User is not JSON serializable

kombu.exceptions.EncodeError: User is not JSON serializable Question: I have django 1.11.5 app with celery 4.1.0 and I recived all the time: kombu.exceptions.EncodeError: <User: testuser> is not JSON serializable my settings.py: CELERY_BROKER_URL = ‘amqp://localhost’ CELERY_RESULT_BACKEND = ‘amqp://localhost’ CELERY_ACCEPT_CONTENT = [‘application/json’] CELERY_RESULT_SERIALIZER = ‘json’ CELERY_TASK_SERIALIZER = ‘json’ CELERY_TIMEZONE = ‘Asia/Makassar’ CELERY_BEAT_SCHEDULE = {} tasks.py from __future__ import …

Total answers: 3

Tasks being repeated in Celery

Tasks being repeated in Celery Question: After a couple days, my celery service will repeat a task over and over indefinitely. This is somewhat difficult to reproduce, but happens regularly once a week or more frequently depending on the tasks volume being processed. I will appreciate any tips on how to get more data about …

Total answers: 3

Celery is rerunning long running completed tasks over and over

Celery is rerunning long running completed tasks over and over Question: I’ve a python celery-redis queue processing uploads and downloads worth gigs and gigs of data at a time. Few of the uploads takes upto few hours. However once such a task finishes, I’m witnessing this bizarre celery behaviour that the celery scheduler is rerunning …

Total answers: 1

Celery tasks not throwing exception in Django Tests

Celery tasks not throwing exception in Django Tests Question: I have a couple of celery tasks that are included in my Django tests. Unfortunately exceptions are not thrown when tasks are invoked via .delay(). I am setting CELERY_ALWAYS_EAGER to True. tasks.py import celeryapp as app @app.task() def exception_task(): print ‘CELERY_ALWAYS_EAGER:’, app.conf[‘CELERY_ALWAYS_EAGER’] raise Exception(‘foo’) tests.py def …

Total answers: 3

How can I run a celery periodic task from the shell manually?

How can I run a celery periodic task from the shell manually? Question: I’m using celery and django-celery. I have defined a periodic task that I’d like to test. Is it possible to run the periodic task from the shell manually so that I view the console output? Asked By: Mridang Agarwalla || Source Answers: …

Total answers: 3