I’m curious that why the “early exit” behavior doesn’t happen here, since I didn’t wait the async task
s.jl
println("$PROGRAM_FILE> " *
"threads_setting = $((Threads.nthreads(), Threads.nthreads(:interactive))), " *
"id = $(Threads.threadid()), " *
"pool = $(Threads.threadpool())"
)
function bzwt(t)
tdue = time_ns() + 1e9t
while true
try
time_ns() < tdue || error()
catch
return
end
end
end;
function a()
@ccall printf("a> begins... \n"::Cstring)::Cint
bzwt(1.5)
@ccall printf("a> 1.5s... \n"::Cstring)::Cint
bzwt(1.4)
@ccall printf("a> 1.4s... \n"::Cstring)::Cint
bzwt(1.3)
@ccall printf("a> 1.3s... \n"::Cstring)::Cint
bzwt(1.2)
@ccall printf("a> 1.2s... \n"::Cstring)::Cint
bzwt(1.1)
@ccall printf("a> 1.1s... \n"::Cstring)::Cint
end;
@ccall printf("s.jl> begins... \n"::Cstring)::Cint
const t0 = time_ns()
Threads.@spawn(a())
bzwt(3.6)
@ccall printf("s.jl> 3.6s... \n"::Cstring)::Cint
(3.59e9 < time_ns() - t0 < 3.8e9) || error()
in the shell
❯ julia --threads=1,1 s.jl
s.jl> threads_setting = (1, 1), id = 1, pool = interactive
s.jl> begins...
a> begins...
a> 1.5s...
a> 1.4s...
s.jl> 3.6s...
a> 1.3s...
a> 1.2s...
a> 1.1s...
~/somedir 7s some@some
❯
Why didn’t the s.jl early return to the shell? (i.e. why can I still see the a> 1.3s... and its subsequent lines)
Edit: Let’s create a new topic to discuss this sort of behavior.