Comments (5)
I think two things are happening:
1- Reloading before success: onSuccess is responsible for updating the UI (turning the bar green). You override onSuccess, so the task is finished but the UI isn't updated. To preserve the default behaviour when overriding, call this.onSuccessDefault in your custom handler and give it all the arguments. Like this:
onSuccess: function(...args) {
this.onSuccessDefault(...args);
// Custom success behaviour
}
2- Continuous reloading: The task result is still stored in the backend. So when the frontend asks for task status, it finds that the task finished successfully and triggers the onSuccess handler which causes reloading. So everything is working as expected. What's your desired behaviour?
from celery-progress.
Thank you very much for your prompt response. With respect to the continuous reloading, that makes perfect sense; the task result is SUCCESS so it will fire the onSuccess handler upon page load. I added some logic to check for the presence of a different UI element to determine whether the page had already reloaded, which solved that issue.
With respect tot he default handler, though, I am now receiving an error stating that this.onSuccessDefault does not exist. My script is now:
{% if task_id %}
<script src="{% static 'celery_progress/celery_progress.js' %}"></script>
<script>
$(function () {
var progressUrl = "{% url 'celery_progress:task_status' task_id %}"
CeleryProgressBar.initProgressBar(progressUrl, {
onSuccess: function(...args) {
this.onSuccessDefault(...args);
if (!$('#comparison3-tab').hasClass("disabled")) {
location.reload();
}
}
});
});
</script>
{% endif %}
and the error received is:
(index):1084 Uncaught (in promise) TypeError: this.onSuccessDefault is not a function
at CeleryProgressBar.onSuccess ((index):1084)
at CeleryProgressBar.onData (celery_progress.js:80)
at CeleryProgressBar.connect (celery_progress.js:115)
from celery-progress.
You are right. I was testing on the unreleased version.
The way to reference onSuccessDefault was changed in #62 but it's not included in the latest release yet.
On the current version (0.0.14), use CeleryProgressBar.onSuccessDefault.
On later versions, use this.onSuccessDefault.
from celery-progress.
works great! Thanks!
from celery-progress.
Sorry about that!
I just pushed a new release (0.1.0
- because I don't really know why I ever started with 0.0...
🤷♂️ ). Feel free to install that one and let me know if there are any issues!
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
- Task_id must not be empty. Got None instead HOT 7
- Intermittent Issue with Starting of Celery Task HOT 9
- 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.