Skip to content

Commit 2c8408c

Browse files
kpamnanyIanButterworth
authored andcommitted
Use correct threads specification for subprocess (JuliaLang#3467)
(cherry picked from commit 9f277c4)
1 parent b426fb8 commit 2c8408c

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/Operations.jl

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1659,6 +1659,20 @@ function gen_test_precompile_code(source_path::String; coverage, julia_args::Cmd
16591659
return gen_subprocess_cmd(code, source_path; coverage, julia_args)
16601660
end
16611661

1662+
@static if VERSION >= v"1.9.0" # has threadpools
1663+
function get_threads_spec()
1664+
if Threads.nthreads(:interactive) > 0
1665+
"$(Threads.nthreads(:default)),$(Threads.nthreads(:interactive))"
1666+
else
1667+
"$(Threads.nthreads(:default))"
1668+
end
1669+
end
1670+
else # no threadpools
1671+
function get_threads_spec()
1672+
"$(Threads.nthreads())"
1673+
end
1674+
end
1675+
16621676
function gen_subprocess_cmd(code::String, source_path::String; coverage, julia_args)
16631677
coverage_arg = if coverage isa Bool
16641678
coverage ? string("@", source_path) : "none"
@@ -1677,7 +1691,7 @@ function gen_subprocess_cmd(code::String, source_path::String; coverage, julia_a
16771691
--inline=$(Bool(Base.JLOptions().can_inline) ? "yes" : "no")
16781692
--startup-file=$(Base.JLOptions().startupfile == 1 ? "yes" : "no")
16791693
--track-allocation=$(("none", "user", "all")[Base.JLOptions().malloc_log + 1])
1680-
--threads=$(Threads.nthreads())
1694+
--threads=$(get_threads_spec())
16811695
$(julia_args)
16821696
--eval $(code)
16831697
```

0 commit comments

Comments
 (0)