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

How to cancel taskflow that has executed future.get()? #555

Open
QiuYilin opened this issue Feb 22, 2024 · 4 comments
Open

How to cancel taskflow that has executed future.get()? #555

QiuYilin opened this issue Feb 22, 2024 · 4 comments
Labels
question Further information is requested

Comments

@QiuYilin
Copy link

QiuYilin commented Feb 22, 2024

I need to grab the exception for each task. like this:

try{
  tf::Future<void> fu = executor.run(taskflow);
  fu.get();
}
catch(...){
  do_something();
}

Then the thread will be blocked because of future's feature. The cancel() method won't work after get().Is there any way to catch exceptions while retaining the ability to interrupt tasks?

@tsung-wei-huang tsung-wei-huang added the question Further information is requested label Feb 24, 2024
@tsung-wei-huang
Copy link
Member

Hi @QiuYilin , I don't understand your question. Basically, when an exception is thrown, the taskflow runtime will try to cancel that running taskflow. Is this something you were asking for?

@QiuYilin
Copy link
Author

Hi @QiuYilin , I don't understand your question. Basically, when an exception is thrown, the taskflow runtime will try to cancel that running taskflow. Is this something you were asking for?

I want to actively interrupt the task even if there is no error. Now I think I should create my own breakpoint, pass the flag so that the breakpoint throws an exception, so as to achieve the effect instead of using future.cancel().

@tsung-wei-huang
Copy link
Member

I think you are referring to something like coroutine that you can suspend a task at any point? If yes, this is something currently we are working on.

@QiuYilin
Copy link
Author

What I mean is that the task can be interrupted, but it does not affect the acquisition of exceptions without interruption.What I need may be InterruptableThread, I don't need to continue executing the interrupted task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants