@@ -1946,11 +1946,11 @@ end
1946
1946
starting_managers = []
1947
1947
started_workers = Int[]
1948
1948
exiting_workers = Int[]
1949
- exited_workers = Int []
1949
+ exited_workers = []
1950
1950
starting_key = DistributedNext. add_worker_starting_callback ((manager, kwargs) -> push! (starting_managers, manager))
1951
1951
started_key = DistributedNext. add_worker_started_callback (pid -> (push! (started_workers, pid); error (" foo" )))
1952
1952
exiting_key = DistributedNext. add_worker_exiting_callback (pid -> push! (exiting_workers, pid))
1953
- exited_key = DistributedNext. add_worker_exited_callback (pid -> push! (exited_workers, pid))
1953
+ exited_key = DistributedNext. add_worker_exited_callback (( pid, state) -> push! (exited_workers, ( pid, state) ))
1954
1954
1955
1955
# Test that the worker-started exception bubbles up
1956
1956
@test_throws TaskFailedException addprocs (1 )
@@ -1960,7 +1960,7 @@ end
1960
1960
@test started_workers == [pid]
1961
1961
rmprocs (workers ())
1962
1962
@test exiting_workers == [pid]
1963
- @test exited_workers == [pid]
1963
+ @test exited_workers == [( pid, DistributedNext . WorkerState_terminated) ]
1964
1964
1965
1965
# Trying to reset an existing callback should fail
1966
1966
@test_throws ArgumentError DistributedNext. add_worker_started_callback (Returns (nothing ); key= started_key)
@@ -1992,6 +1992,17 @@ end
1992
1992
@test length (started_workers) == 1
1993
1993
@test length (exiting_workers) == 1
1994
1994
@test length (exited_workers) == 1
1995
+
1996
+ # Test that workers that were killed forcefully are detected as such
1997
+ exit_state = nothing
1998
+ DistributedNext. add_worker_exited_callback ((pid, state) -> exit_state = state)
1999
+ pid = only (addprocs (1 ))
2000
+
2001
+ redirect_stderr (devnull ) do
2002
+ remote_do (exit, pid)
2003
+ timedwait (() -> ! isnothing (exit_state), 10 )
2004
+ end
2005
+ @test exit_state == DistributedNext. WorkerState_exterminated
1995
2006
end
1996
2007
1997
2008
# This is a simplified copy of a test from Revise.jl's tests
0 commit comments