@@ -1946,11 +1946,11 @@ end
19461946 starting_managers = []
19471947 started_workers = Int[]
19481948 exiting_workers = Int[]
1949- exited_workers = Int []
1949+ exited_workers = []
19501950 starting_key = DistributedNext. add_worker_starting_callback ((manager, kwargs) -> push! (starting_managers, manager))
19511951 started_key = DistributedNext. add_worker_started_callback (pid -> (push! (started_workers, pid); error (" foo" )))
19521952 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) ))
19541954
19551955 # Test that the worker-started exception bubbles up
19561956 @test_throws TaskFailedException addprocs (1 )
@@ -1960,7 +1960,7 @@ end
19601960 @test started_workers == [pid]
19611961 rmprocs (workers ())
19621962 @test exiting_workers == [pid]
1963- @test exited_workers == [pid]
1963+ @test exited_workers == [( pid, DistributedNext . WorkerState_terminated) ]
19641964
19651965 # Trying to reset an existing callback should fail
19661966 @test_throws ArgumentError DistributedNext. add_worker_started_callback (Returns (nothing ); key= started_key)
@@ -1992,6 +1992,17 @@ end
19921992 @test length (started_workers) == 1
19931993 @test length (exiting_workers) == 1
19941994 @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
19952006end
19962007
19972008# This is a simplified copy of a test from Revise.jl's tests
0 commit comments