Comments (8)
If we choose to keep stop_task
, the only suitable solution that comes to mind would be something like this:
def stop_task(exc):
raise (exc if isinstance(exc, Exception) else Exception(exc))
This would have the exact same effect as the what the previous implementation aimed to accomplish, with the caveat that the bar would still go to 100%. In order for us to maintain the current state of the progress bar vs filling it completely, we would have to make changes to the client-side JavaScript to somehow interpret that from the response, and we would have to modify how Progress.get_info
sets the progress state for "completed" tasks to detect failures vs. successes, as right now both states just return the "completed" task state.
In the end, all of this is just extra work to offer a crutch for actually just raising the error yourself. Heck, it even takes more characters to type stop_task(exc=exc)
instead of raise exc
. ConsoleProgressRecorder
's method doesn't even do anything! While I understand the valid concern for whether or not we should cater to entry-level programmers, I would think that if they've somehow managed to set up a Django webserver that requires progress bars, they would have at some point come across the try/except logic and exception raising.
from celery-progress.
Another thought that came to my mind, stop_task
may only makes sense if a start_task
method existed. However, I don't think it should be the focus of the celery-progress
utility, instead make it as simple as possible to manage the progress/status of a running task. If the two start and end points (creating/activating and ending/killing) stay true to Celery, then one should have no problem implementing those using Celery's documentation.
from celery-progress.
I think you lay out a compelling case and I'm happy to deprecate/remove support for it. It's not a feature that I've ever had the need for, and I just merged in the enhancement since it seemed to be useful to others.
Re-reading that PR, it does seem like the core use case of providing input on a failure within the task is better handled through the ways you've outlined.
from celery-progress.
The first time I used celery-progress, I got confused with stop_task
. I thought it would nicely handle the killing of the task (eg. raise the exception) and freeze the progress bar displaying the error message. But it did none of those things so I quickly move away from it.
If it can be made more useful (eg. my initial expectation and/or more) I think it could be nice for novices like me to have a quick hook to stop the on-going progress.
from celery-progress.
Although, for a possible counter-argument, keeping stop_task
in the modified form would allow users to subclass the bar and add their own logic. So I guess the argument at that point becomes "it's a crutch for actual Python" vs. "user extendibility". Decisions, decisions...
from celery-progress.
@EJH2 you have my support on whatever you think makes sense on this 😄
Sorry if I'm acting a bit hands off - I just don't have any strong opinions on this particular topic. Plus, I think you're doing a great job stewarding the lib and trust your judgment.
from celery-progress.
I'm in favour of dropping stop_task
and letting the user simply raise an exception.
The only use case for stop_task
is if you want to ignore the task (which prevents state updates), but you also want to update the state and save the exception. Right? I'm not sure why you would want to do that.
from celery-progress.
It seems that the general consensus is fine with removing the method, so I'll put out a PR that corrects this.
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.