You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
function__run!(job::Job)
# See https://github.com/JuliaLang/julia/issues/21130#issuecomment-288423284@trybeginglobal result = job.def()
@catch e
job.stop_time =now()
@error"come across `$e` when running!"
job.status = e isa InterruptException ? INTERRUPTED : FAILED
return e
@else
job.stop_time =now()
job.status = SUCCEEDED
return result
@finally
job.count +=1endend
After moving the function definition to Thunk, I had the same problem (But since I was using Julia v1.8 to develop, so that was fine):
@tryglobal result = thunk.f(thunk.args...; thunk.kwargs...)
@catch e
setresult!(thunk, e)
return e
@elsesetresult!(thunk, result)
return result
end
But I just found out, I could just use finally and some tricks to avoid else (since try statement do not return what was included in finally):
If no error is raised, thunk.result will be returned; if erred, thunk.result will catch an error and still be returned. No matter what, thunk.evaluated is set to true.
The text was updated successfully, but these errors were encountered:
Before v1.8, Julia does not support the
try ... catch ... else
syntax. So I have to useTryCatch.jl
to do that:After moving the function definition to
Thunk
, I had the same problem (But since I was using Julia v1.8 to develop, so that was fine):But I just found out, I could just use
finally
and some tricks to avoidelse
(sincetry
statement do not return what was included infinally
):If no error is raised,
thunk.result
will be returned; if erred,thunk.result
will catch an error and still be returned. No matter what,thunk.evaluated
is set totrue
.The text was updated successfully, but these errors were encountered: