I simply just break from the loop in my main Tokio process, and if I do await for the executor handle it will run forever which is not what I wanted after Ctrl+C. I wonder what is the best practice to deal with this.
I'm using the parallel feature and I think we will need a task abort mechanism which is likely one of these:
Cancellation token. For each spawned task in ctx, attach a global cancellation token, and when it was triggered, cancel all tasks.
Manually add a cancellation signal for each futures you spawned in ctx. This is similar to cancellation token although it is not mandatory
Use panic abort although this is more of a hail-marry approach (because you will lost valuable debug information for this)
Migrate the executor task to a specific thread, and stop accepting future works. I think this would be the most likely solution as it should be easily implementable.
I am currently redesigning how futures are used in rquickjs in the PR #156.
With this redesign we no longer use tasks to schedule futures spawned by rquickjs.
I want to shutdown the executor when my script ends, but right now it doesn't seems like it is working.
Given that I have these error on Ctrl+C
It seems like the error comes from here: https://github.com/DelSkayn/rquickjs/blob/234cc91ff7a3d06fb5d58fcd8f0e6bed56af51d5/core/src/runtime/async_executor.rs#L106-L113
I simply just break from the loop in my main Tokio process, and if I do await for the executor handle it will run forever which is not what I wanted after Ctrl+C. I wonder what is the best practice to deal with this.
I'm using the
parallel
feature and I think we will need a task abort mechanism which is likely one of these:ctx
, attach a global cancellation token, and when it was triggered, cancel all tasks.ctx
. This is similar to cancellation token although it is not mandatory