Skip to content
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

[PRO] Job(my_celery).Except(this.task_on_exception) transition for Jobs #244

Open
snickell opened this issue Jun 10, 2019 · 3 comments
Open

Comments

@snickell
Copy link

My flows use a LOT of Celery Jobs to process UI input that would take to long to run synchronously in the web process.

It would be very elegant if viewflow.contrib.celery.Job supported a special .Except(this.another_task) that was like .Next(), but used in case the celery job raises an Exception.

my_task = (
    Job(my_celery_job)
    .Except(this.on_my_task_fail)
    .Next(this.on_my_task_success)
)
@kmmbvnr
Copy link
Contributor

kmmbvnr commented Jun 11, 2019

Yep, it's a good idea.

But generally I think using any Exception a bit dangerous, but having specific TaskFailded exception would be good

@variable
Copy link

variable commented Nov 11, 2019

Hi I have created something similar, I have just started using viewflow few days ago, can you please verify my implementation?

https://stackoverflow.com/questions/58794582/django-viewflow-what-is-the-proper-way-to-handle-exceptions-in-handler/58795132#58795132

Like I mentioned in the solution, I cannot find a clean pass to pass the exception to the exception node activation unless in the exception node I use another custom activation to accept the extra constructor argument.

activation = mapping['node'].activate(prev_activation=self, token=self.task.token)
# wish I could just pass like
activation = mapping['node'].activate(prev_activation=self, token=self.task.token, exception=self.caught_exception)

@variable
Copy link

variable commented Mar 3, 2020

@snickell today I encountered the same need for celery job, so I added the CatchExceptionJob to do the same. I have updated my Stackoverflow answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants