Skip to content

Commit 5488684

Browse files
committed
Revert "Remove useless workers variable (#103)"
This reverts commit 7f27702.
1 parent 7f27702 commit 5488684

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

src/ParallelTestRunner.jl

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,7 @@ function runtests(mod::Module, args::ParsedArgs;
791791
jobs::Int = clamp(_jobs, 1, length(tests))
792792
println(stdout, "Running $jobs tests in parallel. If this is too many, specify the `--jobs=N` argument to the tests, or set the `JULIA_CPU_THREADS` environment variable.")
793793
nworkers = min(jobs, length(tests))
794+
workers = fill(nothing, nworkers)
794795

795796
t0 = time()
796797
results = []
@@ -980,7 +981,7 @@ function runtests(mod::Module, args::ParsedArgs;
980981
#
981982

982983
worker_tasks = Task[]
983-
for _ in 1:nworkers
984+
for p in workers
984985
push!(worker_tasks, @async begin
985986
while !done[]
986987
# get a test to run
@@ -1000,11 +1001,14 @@ function runtests(mod::Module, args::ParsedArgs;
10001001
else
10011002
test_worker(test, init_worker_code)
10021003
end
1004+
# Create a new binding instead of assigning to the existing one to avoid `p` from being boxed
1005+
p2 = p
1006+
if wrkr === nothing
1007+
wrkr = p2
1008+
end
10031009
# if a worker failed, spawn a new one
1004-
p = if isnothing(wrkr) || !Malt.isrunning(wrkr)
1005-
wrkr = addworker(; init_worker_code, io_ctx.color)
1006-
else
1007-
nothing
1010+
if wrkr === nothing || !Malt.isrunning(wrkr)
1011+
wrkr = p2 = addworker(; init_worker_code, io_ctx.color)
10081012
end
10091013

10101014
# run the test
@@ -1053,7 +1057,7 @@ function runtests(mod::Module, args::ParsedArgs;
10531057
end
10541058

10551059
# get rid of the custom worker
1056-
if wrkr != p
1060+
if wrkr != p2
10571061
Malt.stop(wrkr)
10581062
end
10591063

0 commit comments

Comments
 (0)