-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Revoked State #63
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me, thanks!
"""Runs if a task has been revoked. This will be used to push a websocket update for revoked events. | ||
|
||
If the websockets version of this package is not installed, this will fail silently.""" | ||
_result = ('terminated' if kwargs.pop('terminated') else None) or ('expired' if kwargs.pop('expired') else None) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the value used in line 79 in get_info? How is it populated for HTTP? I just want to ensure WS and HTTP behave the same because this looks hand-crafted but the HTTP code uses a single source (result.info).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the result.info
value that gets used at that line, yes. HTTP populates this value by requesting the backend, which has the same values. The handler for revoked tasks does not pass the result, so I had to manually re-create the intended result in order to maintain parity with HTTP. All of the same data is there, it's just that rather than making a trip to the backend, I've opted to use what I've already been provided to do largely the same thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. Unfortunate that result.info is not well documented in celery.
On second thought, I might remove the |
This PR adds (more) support for the REVOKED task state as discussed in #54. Notable changes in this PR include:
task_revoked_handler
in websockets/tasks.py to handle revoked/terminated/expired tasks.Progress.get_info()
now usescelery.states
for state comparisons. This should make the comparisons a tad clearer on what they actually are.self.result.ready()
, as that was intercepting REVOKED task states and not allowing us to pretty up the output before shipping to the frontend.Sample outputs can be seen below: