Skip to content

Commit 0b5ef17

Browse files
committed
Move the initialisation to __init__()
1 parent ba4f30e commit 0b5ef17

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/DynamicPPL.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,12 @@ include("test_utils.jl")
205205
include("experimental.jl")
206206
include("deprecated.jl")
207207

208-
if isdefined(Base.Experimental, :register_error_hint)
209-
function __init__()
208+
function __init__()
209+
# This has to be in the `__init__()` function, if it's placed at the top level it
210+
# always evaluates to false.
211+
DynamicPPL.set_threadsafe_eval!(Threads.nthreads() > 1)
212+
213+
if isdefined(Base.Experimental, :register_error_hint)
210214
# Better error message if users forget to load JET.jl
211215
Base.Experimental.register_error_hint(MethodError) do io, exc, argtypes, _
212216
requires_jet =

src/model.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const USE_THREADSAFE_EVAL = Ref(Threads.nthreads() > 1)
1+
USE_THREADSAFE_EVAL = Ref(true)
22

33
"""
44
DynamicPPL.set_threadsafe_eval!(val::Bool)

0 commit comments

Comments
 (0)