Skip to content

Status of the Task PENDING #7110

@premanandaembed

Description

@premanandaembed

i'm using Window 11 and windows redis exe redis-2.4.5-win32-win64 64bit folder i'm getting task id but i'm always getting state value as PENDING what will be reason.

app.py file as:
from celery import Celery
from flask import Flask

app = Flask(name)
simple_app = Celery('simple_worker', broker='redis://127.0.0.1:6379/0', backend='redis://127.0.0.1:6379/0')
simple_app.conf.CELERY_TASK_TRACK_STARTED = True

@app.route('/simple_start_task')
def call_method():
app.logger.info("Invoking Method ")
# queue name in task folder.function name
r = simple_app.send_task('tasks.longtime_add', kwargs={'x': 1, 'y': 2})
app.logger.info(r.backend)
print(simple_app.conf["CELERY_IGNORE_RESULT"])
return r.id

@app.route('/simple_task_status/<task_id>')
def get_status(task_id):
status = simple_app.AsyncResult(task_id, app=simple_app)
print("Invoking Method ")
return "Status of the Task " + str(status.state)

@app.route('/simple_task_result/<task_id>')
def task_result(task_id):
result = simple_app.AsyncResult(task_id).result
return "Result of the Task " + str(result)

if name == 'main':
app.run(host="127.0.0.1", port=5555)

tasks.py file as:
from celery.utils.log import get_task_logger

logger = get_task_logger(name)

app = Celery('tasks', broker='redis://127.0.0.1:6379/0', backend='redis://127.0.0.1:6379/0')
app.conf.CELERY_TASK_TRACK_STARTED = True

@app.task()
def longtime_add(x, y):
logger.info('Got Request - Starting work ')
time.sleep(4)
logger.info('Work Finished ')
return x + y

let me know what wrong with two file.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions