Giter VIP home page Giter VIP logo

Comments (15)

czue avatar czue commented on June 16, 2024 2

Oh dear, sorry about the delayed reply.

If the task is called in the view and then you are rendering the progress bar on the resulting page then you should just pass task_id directly from the view.

See this section of the readme for how that looks.

If you are triggering the task from the page itself (e.g. via ajax or something) it's a bit trickier. One hack you can do is something like the below using a stub task id to get the URL:

// on page load
var progressUrl = "{% url 'celery_progress:task_status' 'task-id-stub' %}";
// in callback function - assumes api response returns the task id
var taskUrl = progressUrl.replace('task-id-stub', response.text);

Does that help?

from celery-progress.

sindhujit avatar sindhujit commented on June 16, 2024

I have the same issue. +1. Where is the task_id actually defined?

from celery-progress.

snmateen avatar snmateen commented on June 16, 2024

i'm seeing the same issue as well.

django.urls.exceptions.NoReverseMatch: Reverse for 'task_status' with arguments '('',)' not found. 1 pattern(s) tried: ['celery-progress/(?P<task_id>[\\w-]+)/$']

from celery-progress.

nonnimartin avatar nonnimartin commented on June 16, 2024

Same issue. Any suggestions?

from celery-progress.

lie-nielsen avatar lie-nielsen commented on June 16, 2024

In settings.py, try this:
path('celery-progress/', include('celery_progress.urls')),

from celery-progress.

Acessos-Ad3 avatar Acessos-Ad3 commented on June 16, 2024

Hi, czue
I'm with the same issue, i tried your answer but, didn't worked for me,

from celery-progress.

czue avatar czue commented on June 16, 2024

Can you share your view code and template?

from celery-progress.

AmineHosni avatar AmineHosni commented on June 16, 2024

Same here. My console shows

Failed to load resource: the server responded with a status of 500 (Internal Server Error) at
127.0.0.1:8000/celery-progress/bddc2f0a-91d5-42ca-bf94-a5deb8d55305/ which shows the Django error:
'DisabledBackend' object has no attribute '_get_task_meta_for'

I added these lines, based on the 2nd solution, right before the task definition
from celery import Celery
app = Celery('tasks', backend='rpc://', broker='pyamqp://')

With this code in the Views,

def pdf_add(request, slug):
        if form.is_valid():
                # some code to upload a pdf file and split each page into .pdf and .jpg 
                # for further work
                # below work is just a sample example to test the library
		result = obj.my_task.delay(10)
		context['task_id'] = result.task_id
		return redirect('projects_details',project.slug)
	pdf = PDF_file()
	result = pdf.my_task.delay(10)
	context['task_id'] = result.task_id
	return render(request, template_name, context)

Doing so, removes the console error as it now has a backend but not the one of celery-progress (I think), I even see my terminal refreshing every second with Get / celery-progress/some_task_id but the "0 of 100 proceeded" doesn't change when the task is called.
I also tried adding this line, based on the 3rd solution on the same previous link:
CELERY_RESULT_BACKEND='djcelery.backends.database:DatabaseBackend' but it didn't change a thing.
I don't know how to make it pick the library's backend.
And if I remove the pdf = PDF_file() result = pdf.my_task.delay(10) context['task_id'] = result.task_id
from the GET part of the View function, I'm back to the starting problem with NoReverseMatch..." error back

from celery-progress.

czue avatar czue commented on June 16, 2024

celery and your web app (I assume django) need to use the same backend.

So if you're using rpc:// when you call celery then you should add CELERY_RESULT_BACKEND='rpc://' to settings.py I believe.

from celery-progress.

sindhujit avatar sindhujit commented on June 16, 2024

Hi @czue
I followed the corrections you stated. For me, the no reverse error is fixed. However, the issue now is we are getting the task ID only after the task is completely executed. So the progress does not start until the entire task is completed. Do we need to send 2 ajax requests, one where we return only the task_id and other for the other variables involved in the task which I want in my front-end?

from celery-progress.

czue avatar czue commented on June 16, 2024

Are you using ALWAYS_EAGER? That would cause the task to be executed synchronously.

from celery-progress.

ludwigwittgenstein2 avatar ludwigwittgenstein2 commented on June 16, 2024

I have the same issue.
image

from celery-progress.

czue avatar czue commented on June 16, 2024

@ludwigwittgenstein2 it looks like the task ID is blank, which either means you're not properly passing it to the template, or the celery setup is not returning valid task IDs (check the result backend).

from celery-progress.

czue avatar czue commented on June 16, 2024

Closing this out since I believe this is a configuration problem and not an issue with the library.

from celery-progress.

phatberstromgg avatar phatberstromgg commented on June 16, 2024

Hi @czue, I have tried your advice but the error still there. In my case, the webpage was worked but when I upload a video, the web shows me the error. It is said the same look as the post of @ludwigwittgenstein2. Could you help me, please? Hope to hear from you soon.

Thank you so much.
Best regards.

Oh dear, sorry about the delayed reply.

If the task is called in the view and then you are rendering the progress bar on the resulting page then you should just pass task_id directly from the view.

See this section of the readme for how that looks.

If you are triggering the task from the page itself (e.g. via ajax or something) it's a bit trickier. One hack you can do is something like the below using a stub task id to get the URL:

// on page load
var progressUrl = "{% url 'celery_progress:task_status' 'task-id-stub' %}";
// in callback function - assumes api response returns the task id
var taskUrl = progressUrl.replace('task-id-stub', response.text);

Does that help?

from celery-progress.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.