I recently found that throwto()
never returns, it just hangs (see this GitHub issue) and constructed a little demo:
task = @async begin
while true
print("-")
end
end
sleep(0.003)
println("Throwing...")
Base.throwto(task, InterruptException())
println("Thrown.")
Perhaps this is better at home in New To Julia, but this has left me both confused and intrigued.
- Why? Was there a conscious design choice gone into that behaviour?
- In the case where I may have any number of tasks where instead of
println("-")
it is a blocking call that takes an unknown (potentially infinite) amount of time (egreadbytes!(mysocket, mylist, 4)
), how can I stop a task in middle of a blocking call from outside the task?