There’s a really simple mistake in your example but unfortunately you never get a useful error message to help you track it down. The problem is that your function f is not defined on the worker you try to run it on. You run
Distributed.@everywhere function f()
return 42
end
at the top of your script but then start a new worker later on in the main function. You then try to run f on the new worker. When you run something with @everywhere it only runs it on the worker processes that are currently running. Julia doesn’t keep track of previous uses of @everywhere and automatically run them when new worker processes are started.
If you change your example to
using Distributed
addprocs(1)
Distributed.@everywhere function f()
return 42
end
...
function main()
@show ptimeout(f, 10; worker = 2)
end
then the example works for me.
Having said all that, I’m not sure why you don’t see an error printed to the screen about the function not being defined.