Is it possible to catch a SIGINT to stop a Julia program from running, but doing so in an "orderly" fashion?
function many_calc(number)
terminated_by_sigint = false
a = rand(number)
where_are_we = 0
for i in eachindex(a)
where_are_we = i
# do something slow...
sleep(1)
a[i] += rand()
end
a, where_are_we, terminated_by_sigint
end
many_calc(100)
Say I want to end it efter 30 seconds, because I didn't realize it would take so long, but don't want to throw away all the results, because I have another method to continue from where_are_we-1
. Is it at all possible to stop it (softly) early, but using the SIGINT signal?