Skip to content

Commit e6e1fb2

Browse files
committed
Sch: Exit properly on scheduler failure
1 parent 7b811ba commit e6e1fb2

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Diff for: src/sch/eager.jl

+9-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ function init_eager()
1717
end
1818
if Threads.atomic_xchg!(EAGER_INIT, true)
1919
wait(EAGER_READY)
20+
if EAGER_STATE[] === nothing
21+
throw(ConcurrencyViolationError("Eager scheduler failed to start"))
22+
end
2023
return
2124
end
2225
ctx = eager_context()
@@ -38,14 +41,19 @@ function init_eager()
3841
seek(iob.io, 0)
3942
write(stderr, iob)
4043
finally
41-
reset(EAGER_READY)
44+
# N.B. Sequence order matters to ensure that observers can see that we failed to start
4245
EAGER_STATE[] = nothing
46+
notify(EAGER_READY)
47+
reset(EAGER_READY)
4348
lock(EAGER_ID_MAP) do id_map
4449
empty!(id_map)
4550
end
4651
Threads.atomic_xchg!(EAGER_INIT, false)
4752
end)
4853
wait(EAGER_READY)
54+
if EAGER_STATE[] === nothing
55+
throw(ConcurrencyViolationError("Eager scheduler failed to start"))
56+
end
4957
end
5058
function eager_thunk()
5159
exec!(Dagger.sch_handle()) do ctx, state, task, tid, _

0 commit comments

Comments
 (0)