<div dir="ltr">Do you have the same version of user_default on all the nodes? You try to execute a local fun remotely, it will only work if you have exactly the same version of the beams on all the nodes.<div><br></div><div>Cheers,</div><div>Daniel<br><br><div class="gmail_quote"><div dir="ltr">On Tue, 6 Dec 2016 at 11:35 Khitai Pang <<a href="mailto:khitai.pang@outlook.com">khitai.pang@outlook.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000" class="gmail_msg">
Hi Adrian,<br class="gmail_msg">
<br class="gmail_msg">
Thank you for the information but unfortunately it's not the cause of my problem. If I add 'user' io:format():<br class="gmail_msg">
<br class="gmail_msg">
(myapp@testhost1)6> run_on_all_nodes().<br class="gmail_msg">
[<27616.12396.0>,<27612.19603.39>,<27615.48.51>]<br class="gmail_msg">
<br class="gmail_msg">
(myapp@testhost1)7> [spawn(Node, fun() -> io:format(user, "This runs on ~p~n", [node()]) end) || Node <- nodes()].<br class="gmail_msg">
[<27616.12397.0>,<27612.19600.39>,<27615.77.51>]<br class="gmail_msg">
<br class="gmail_msg">
(myapp@testhost1)8> [spawn(Node, fun() -> io:format("This runs on ~p~n", [node()]) end) || Node <- nodes()].</div><div bgcolor="#FFFFFF" text="#000000" class="gmail_msg"><br class="gmail_msg">
This runs on myapp@testhost2<br class="gmail_msg">
This runs on rabbit@testhost1<br class="gmail_msg">
This runs on rabbit@testhost2<br class="gmail_msg"></div><div bgcolor="#FFFFFF" text="#000000" class="gmail_msg">
[<27616.12398.0>,<27612.19631.39>,<27615.89.51>]<br class="gmail_msg">
<br class="gmail_msg">
It doesn't seem to be I/O channeling problem, it seems that the spawned processes just don't run...<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
Thanks</div><div bgcolor="#FFFFFF" text="#000000" class="gmail_msg"><br class="gmail_msg">
khitai</div><div bgcolor="#FFFFFF" text="#000000" class="gmail_msg"><br class="gmail_msg">
<br class="gmail_msg">
<div class="m_1422482366369241958moz-cite-prefix gmail_msg">On 2016/12/6 17:52, Adrian Roe wrote:<br class="gmail_msg">
</div>
<blockquote type="cite" class="gmail_msg">
<div class="gmail_msg">This confused me for a while as well…</div>
<div class="gmail_msg"><br class="gmail_msg">
</div>
<div class="gmail_msg">To quote <a href="http://erlang.org/doc/man/erlang.html" class="gmail_msg" target="_blank">http://erlang.org/doc/man/erlang.html</a></div>
<div class="gmail_msg"><br class="gmail_msg">
</div>
<div class="gmail_msg">
<p style="font-family:Verdana,Arial,Helvetica,sans-serif;font-size:medium;font-variant-ligatures:normal;background-color:rgb(255,255,255)" class="gmail_msg">
<span class="m_1422482366369241958bold_code gmail_msg" style="font-family:Courier,monospace;font-weight:bold">group_leader() -> pid()</span><br class="gmail_msg">
</p>
<div class="m_1422482366369241958REFBODY gmail_msg" style="margin-left:13mm;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:medium;font-variant-ligatures:normal;background-color:rgb(255,255,255)">
<div class="gmail_msg"><br class="m_1422482366369241958webkit-block-placeholder gmail_msg">
</div>
<p class="gmail_msg">Returns the process identifier of the group leader for the process evaluating the function.</p>
<p class="gmail_msg">Every process is a member of some process group and all groups have a <strong class="gmail_msg">group leader</strong>. All I/O from the group is channeled to the group leader. When a new process is spawned, it gets the same group leader as the spawning process.
Initially, at system startup, <span class="m_1422482366369241958code gmail_msg" style="font-family:Courier,monospace">init</span> is both its own group leader and the group leader of all processes.</p>
</div>
</div>
<div class="gmail_msg">There’s a helpful post here <a href="http://erlang.org/pipermail/erlang-questions/2008-April/034573.html" class="gmail_msg" target="_blank"></a><a class="m_1422482366369241958moz-txt-link-freetext gmail_msg" href="http://erlang.org/pipermail/erlang-questions/2008-April/034573.html" target="_blank">http://erlang.org/pipermail/erlang-questions/2008-April/034573.html</a> that
talks about exactly what you are seeing.</div>
<div class="gmail_msg"><br class="gmail_msg">
</div>
<div class="gmail_msg">If you change the </div>
<div class="gmail_msg"><span class="m_1422482366369241958Apple-tab-span gmail_msg" style="white-space:pre-wrap"></span>io:format("This runs on ~p~n", [node()]) </div>
<div class="gmail_msg">to </div>
<div class="gmail_msg"><span class="m_1422482366369241958Apple-tab-span gmail_msg" style="white-space:pre-wrap"></span>io:format(user, "This runs on ~p~n", [node()])</div>
<div class="gmail_msg"><br class="gmail_msg">
</div>
<div class="gmail_msg">I strongly suspect you will see the output you were expecting…</div>
<div class="gmail_msg"><br class="gmail_msg">
</div>
<div class="gmail_msg">Adrian</div>
<div class="gmail_msg"><br class="gmail_msg">
</div>
<div class="gmail_msg">
<div class="gmail_msg">
<blockquote type="cite" class="gmail_msg">
<div class="gmail_msg">On 6 Dec 2016, at 09:34, Khitai Pang <<a href="mailto:khitai.pang@outlook.com" class="gmail_msg" target="_blank"></a><a class="m_1422482366369241958moz-txt-link-abbreviated gmail_msg" href="mailto:khitai.pang@outlook.com" target="_blank">khitai.pang@outlook.com</a>> wrote:</div>
<br class="m_1422482366369241958Apple-interchange-newline gmail_msg">
<div class="gmail_msg">
<div class="gmail_msg">Hi,<br class="gmail_msg">
<br class="gmail_msg">
I have the following function in user_default.erl:<br class="gmail_msg">
<br class="gmail_msg">
run_on_all_nodes() -><br class="gmail_msg">
[spawn(Node, fun() -><br class="gmail_msg">
io:format("This runs on ~p~n", [node()])<br class="gmail_msg">
end) || Node <- nodes()].<br class="gmail_msg">
<br class="gmail_msg">
When I run this function, processes can be spawned on remote nodes but <br class="gmail_msg">
it seems that they don't run:<br class="gmail_msg">
<br class="gmail_msg">
(myapp@testhost1)1> nodes().<br class="gmail_msg">
[myapp@testhost2,rabbit@testhost1,rabbit@testhost2]<br class="gmail_msg">
<br class="gmail_msg">
(myapp@testhost1)2> run_on_all_nodes().<br class="gmail_msg">
[<27616.12336.0>,<27612.15341.39>,<27615.22399.50>]<br class="gmail_msg">
<br class="gmail_msg">
If I manually run the spawn command in the attached shell, it all works <br class="gmail_msg">
fine:<br class="gmail_msg">
<br class="gmail_msg">
(myapp@testhost1)3> [spawn(Node, fun() -> io:format("This runs on ~p~n", <br class="gmail_msg">
[node()]) end) || Node <- nodes()].<br class="gmail_msg">
This runs on myapp@testhost2<br class="gmail_msg">
This runs on rabbit@testhost1<br class="gmail_msg">
This runs on rabbit@testhost2<br class="gmail_msg">
[<27616.12339.0>,<27612.15569.39>,<27615.22640.50>]<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
Any idea?<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
Thanks<br class="gmail_msg">
Khitai<br class="gmail_msg">
_______________________________________________<br class="gmail_msg">
erlang-questions mailing list<br class="gmail_msg">
<a href="mailto:erlang-questions@erlang.org" class="gmail_msg" target="_blank">erlang-questions@erlang.org</a><br class="gmail_msg">
<a class="m_1422482366369241958moz-txt-link-freetext gmail_msg" href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br class="gmail_msg">
</div>
</div>
</blockquote>
</div>
<br class="gmail_msg">
</div>
</blockquote>
<br class="gmail_msg">
</div>
_______________________________________________<br class="gmail_msg">
erlang-questions mailing list<br class="gmail_msg">
<a href="mailto:erlang-questions@erlang.org" class="gmail_msg" target="_blank">erlang-questions@erlang.org</a><br class="gmail_msg">
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" class="gmail_msg" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br class="gmail_msg">
</blockquote></div></div></div>