Skip to content

Commit a17e1b5

Browse files
committed
Make Dagger.cancel!() handle a shutting down/shutdown scheduler
1 parent 7a1b408 commit a17e1b5

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

Diff for: src/cancellation.jl

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1+
"""
2+
cancel!(tid=nothing; sch_uid=nothing, force=false, halt_sch=false)
3+
4+
Cancel a running thunk. Note that if the scheduler has already shut down this
5+
will not do anything.
6+
"""
17
function cancel!(tid::Union{Int,Nothing}=nothing;
28
sch_uid::Union{UInt64,Nothing}=nothing,
39
force::Bool=false, halt_sch::Bool=false)
410
remotecall_fetch(1, tid, sch_uid, force, halt_sch) do tid, sch_uid, force, halt_sch
511
state = Sch.EAGER_STATE[]
6-
@lock state.lock _cancel!(state, tid, sch_uid, force, halt_sch)
12+
13+
# Check that the scheduler isn't stopping or has already stopped
14+
if !isnothing(state) && !state.halt.set
15+
@lock state.lock _cancel!(state, tid, sch_uid, force, halt_sch)
16+
end
717
end
818
end
919
function _cancel!(state, tid, sch_uid, force, halt_sch)

0 commit comments

Comments
 (0)