[erlang-questions] processes spawned on remote nodes don't run

Khitai Pang <>
Tue Dec 6 10:34:48 CET 2016


Hi,

I have the following function in user_default.erl:

run_on_all_nodes() ->
     [spawn(Node, fun() ->
                          io:format("This runs on ~p~n", [node()])
                  end) || Node <- nodes()].

When I run this function, processes can be spawned on remote nodes but 
it seems that they don't run:

()1> nodes().
[]

()2> run_on_all_nodes().
[<27616.12336.0>,<27612.15341.39>,<27615.22399.50>]

If I manually run the spawn command in the attached shell, it all works 
fine:

()3> [spawn(Node, fun() -> io:format("This runs on ~p~n", 
[node()]) end) || Node <- nodes()].
This runs on 
This runs on 
This runs on 
[<27616.12339.0>,<27612.15569.39>,<27615.22640.50>]


Any idea?


Thanks
Khitai


More information about the erlang-questions mailing list