Questions tagged [celery-task]

celery-task is a building block of Celery distributed task queue system

celery-task is a building block of Celery distributed task queue system. Basically, it is a python class, but it can be created out of any callable by @celery.task decorator.

727 questions
239
votes
12 answers

Deleting all pending tasks in celery / rabbitmq

How can I delete all pending tasks without knowing the task_id for each task?
nabizan
  • 3,185
  • 5
  • 26
  • 38
94
votes
3 answers

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

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?
Mridang Agarwalla
  • 43,201
  • 71
  • 221
  • 382
69
votes
1 answer

Difference between different ways to create celery task

I am very confused by looking at different ways of creating a celery task. On the surface they all work the same So, Can someone explain what is the difference between these. 1. from myproject.tasks import app @app.task def foo(): pass 2. from…
MOntu
  • 837
  • 1
  • 6
  • 8
62
votes
6 answers

Celery AttributeError: async error

I have RabbitMQ and Celery running locally on my Mac (OS/X 10.13.4), the following code works locally when I run add.delay(x,y): #!/usr/bin/env python from celery import Celery from celery.utils.log import get_task_logger logger =…
DYoung
  • 841
  • 1
  • 6
  • 11
47
votes
4 answers

How to make a celery task fail from within the task?

Under some conditions, I want to make a celery task fail from within that task. I tried the following: from celery.task import task from celery import states @task() def run_simulation(): if some_condition: …
Meilo
  • 3,378
  • 3
  • 28
  • 34
29
votes
2 answers

Celery: list all tasks, scheduled, active *and* finished

Update for the bounty I'd like a solution that does not involve a monitoring thread, if possible. I know I can view scheduled and active tasks using the Inspect class of my apps Control. i = myapp.control.inspect() currently_running =…
Constantinius
  • 34,183
  • 8
  • 77
  • 85
26
votes
3 answers

Celery stop execution of a chain

I have a check_orders task that's executed periodically. It makes a group of tasks so that I can time how long executing the tasks took, and perform something when they're all done (this is the purpose of res.join [1] and grouped_subs) The tasks…
Salami
  • 2,849
  • 4
  • 24
  • 33
25
votes
4 answers

Airflow - Python file NOT in the same DAG folder

I am trying to use Airflow to execute a simple task python. from __future__ import print_function from airflow.operators.python_operator import PythonOperator from airflow.models import DAG from datetime import datetime, timedelta from pprint…
p.magalhaes
  • 7,595
  • 10
  • 53
  • 108
25
votes
2 answers

Celery Worker Error: ImportError no module named celery

I am getting an import error when I try to start my celery worker. I am not sure what the issue is. Any help would be highly appreciated. My project: email/__init__.py /celery.py I try to run the application by calling : celery worker…
user2216194
  • 691
  • 3
  • 17
  • 27
24
votes
1 answer

Celery task with a time_start attribute in 1970

An inspection of currently running Celery tasks reveals a weird time_start timestamp: >> celery.app.control.inspect().active() {u'celery@worker.hostname': [{u'acknowledged': True, u'args': u'(...,)', u'delivery_info': {u'exchange': u'celery', …
Régis B.
  • 10,092
  • 6
  • 54
  • 90
23
votes
5 answers

kombu.exceptions.EncodeError: User is not JSON serializable

I have django 1.11.5 app with celery 4.1.0 and I recived all the time: kombu.exceptions.EncodeError: is not JSON serializable my settings.py: CELERY_BROKER_URL = 'amqp://localhost' CELERY_RESULT_BACKEND =…
user9357277
  • 253
  • 1
  • 2
  • 5
22
votes
3 answers

Celery task state always pending

I am pretty new to celery and django in general so please excuse my lack of knowledge. I am trying to run a test to do some calculations and wait for the test to finish so that I can make sure it is done for the correct answers. Here is what i…
DoctorWizard
  • 303
  • 1
  • 3
  • 11
21
votes
2 answers

Which pool class should i use prefork, eventlet or gevent in celery?

I have 3 remote workers, each one is running with default pool (prefork) and single task. A single task is taking 2 to 5 minutes for completion as it runs on many different tools and inserts database in ELK. worker command: celery -A project worker…
Md Sadique
  • 211
  • 2
  • 3
20
votes
1 answer

Celery : Execute task after a specific time gap

I want to send an email to my users exactly 48 hours after they have registered.How do i achieve this using celery? If I create a periodic task to send an email, I will have to decide a specific time during which i want to execute that task. I don't…
mukesh
  • 726
  • 1
  • 11
  • 27
20
votes
4 answers

import error in celery

this is the code which i am running: from __future__ import absolute_import from celery import Celery celery1 = Celery('celery',broker='amqp://',backend='amqp://',include=['tasks']) celery1.conf.update( CELERY_TASK_RESULT_EXPIRES=3600, …
amit_183
  • 961
  • 3
  • 19
  • 36
1
2 3
48 49