<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif;"><div><div>If something is in the message queue before init is done executing, that timeout will never get called. Timeout means execute only if nothing else happens during. You should be using self() ! timeout </div><div><div id="MAC_OUTLOOK_SIGNATURE"></div></div></div><div><br></div><div>Sergej</div><div><br></div><span id="OLK_SRC_BODY_SECTION"><div style="font-family:Calibri; font-size:12pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt"><span style="font-weight:bold">From: </span> <<a href="mailto:erlang-questions-bounces@erlang.org">erlang-questions-bounces@erlang.org</a>> on behalf of Matthew Evans<br><span style="font-weight:bold">Date: </span> Monday 27 July 2015 16:25<br><span style="font-weight:bold">To: </span> "<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>"<br><span style="font-weight:bold">Subject: </span> [erlang-questions] gen_server and init<br></div><div><br></div><div><style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style><div class="hmmessage"><div dir="ltr">Hi,<div><br></div><div>We have used this pattern in gen_servers for a long time now:</div><div><br></div><div>init(_) -></div><div>   %% Some stuff</div><div>   {ok, #state{}, 0}.</div><div><br></div><div>%%%</div><div>%%%</div><div><br></div><div>handle_info(timeout, State) -></div><div>    %% Init stuff</div><div>    {noreply,State}</div><div><br></div><div>Basically the idea is to prevent init from blocking and to have init/1 return with a timeout of 0 causing an immediate timeout message to be invoked in the handle_info.</div><div><br></div><div>Here's what's odd. Sometimes this timeout does not fire. It doesn't appear that any message is getting sent, but I would imagine that since it's a registered gen_server there is no way that can happen.</div><div><br></div><div>Does anyone have any ideas?</div><div><br></div><div>We are running vsn 17.1, and ntp is enabled on the host (Linux).</div><div><br></div><div>Thanks</div>                                      </div></div></div>_______________________________________________
erlang-questions mailing list
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>
<a href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a>
</span></body></html>