Comments (15)
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.
I have the same issue. +1. Where is the task_id actually defined?
from celery-progress.
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.
Same issue. Any suggestions?
from celery-progress.
In settings.py, try this:
path('celery-progress/', include('celery_progress.urls')),
from celery-progress.
Hi, czue
I'm with the same issue, i tried your answer but, didn't worked for me,
from celery-progress.
Can you share your view code and template?
from celery-progress.
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.
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.
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.
Are you using ALWAYS_EAGER
? That would cause the task to be executed synchronously.
from celery-progress.
from celery-progress.
@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.
Closing this out since I believe this is a configuration problem and not an issue with the library.
from celery-progress.
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)
- Using master branch leads to Javascript TypeError HOT 1
- DOM only updating last element of the loop while diplaying progress HOT 2
- django.conf.urls.url() deprecated in Django 3+, removed in 4.0 HOT 3
- using websockets with channels_redis 4.0.0+ leads to RuntimeError("Event loop is closed") HOT 2
- NoReverseMatch at /status 'celery_progress' is not a registered namespace HOT 2
- celery Progress on file upload HOT 1
- Get the actual value when onProgress HOT 4
- Update two bars relatively to two workers HOT 6
- Maintenance and support for Django >= 3.1 HOT 3
- Race between creating ProgressRecorder and setting its progress HOT 6
- Introduce changelog HOT 3
- get_progress endpoint allows retrieval of arbitrary tasks HOT 7
- How would one use this progress bar when a task is wrapped in a Django transaction.on_commit? HOT 4
- Create Sdist HOT 9
- Handling a FileResponse HOT 3
- Config Mensages HOT 1
- 'celery_progress' is not a registered namespace
- ajax request using htmx HOT 1
- This could benefit from documantation for how to use it with chord or group based workflows. HOT 4
- Legacy install method will be deprecated soon HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from celery-progress.