I’m trying to get the following to work (or something like it)
function execute(f::Function) exec = Executor() t = schedule(@task try while true run!(exec) yield() end catch e shutdown!(exec) println("done") if !isa(e, InterruptException) println("Shutdown Executor: $e") rethrow(e) end end ) try f(exec) finally println("shutting down") #schedule(@task Base.throwto(t, InterruptException())) Base.throwto(t, InterruptException()) wait(t) end end
But I’m getting strange error I cannot make sense of:
“WARNING: Workqueue inconsistency detected: popfirst!(Workqueue).state != :queued”
or everything hangs.
I get the feeling that maybe the main task not a Task or its acting differently? I’ve read on discourse that you should schedule the throwto, but this also does not work.
What would be a good way to achieve something like this?