<div dir="ltr">In line 47 you do a gen_server call, possibly to your current process, which causes a deadlock and hence the timeout error. Change it to asynchronous gen_server:cast or a direct function call to break the deadlock or don't call gen_server functions from a gen_server in the same module.<br></div><div class="gmail_extra"><br><div class="gmail_quote">2016-12-05 2:43 GMT+01:00 qp <span dir="ltr"><<a href="mailto:quantumpotato@gmail.com" target="_blank">quantumpotato@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">
        <br>
        




            
            

<div>I am trying to update my process's state on a 3 second timer.<br><div class="m_-3039719125478820187gmail-post-text"><pre class="m_-3039719125478820187gmail-lang-erlang m_-3039719125478820187gmail-prettyprint m_-3039719125478820187gmail-prettyprinted"><code><span class="m_-3039719125478820187gmail-kwd">-define</span><span class="m_-3039719125478820187gmail-pln">(</span><span class="m_-3039719125478820187gmail-typ">INTERVAL</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln"> </span><span class="m_-3039719125478820187gmail-lit">3000</span><span class="m_-3039719125478820187gmail-pln">)</span><span class="m_-3039719125478820187gmail-pun">.</span><span class="m_-3039719125478820187gmail-pln">

start_link() ->
    gen_server:start_link(</span><span class="m_-3039719125478820187gmail-lit">?MODULE,</span><span class="m_-3039719125478820187gmail-pln"> []</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln"> [])</span><span class="m_-3039719125478820187gmail-pun">.</span><span class="m_-3039719125478820187gmail-pln">

action(</span><span class="m_-3039719125478820187gmail-typ">Pid</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln"> </span><span class="m_-3039719125478820187gmail-typ">Action</span><span class="m_-3039719125478820187gmail-pln">) ->
  gen_server:</span><span class="m_-3039719125478820187gmail-kwd">call</span><span class="m_-3039719125478820187gmail-pln">(</span><span class="m_-3039719125478820187gmail-typ">Pid</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln"> </span><span class="m_-3039719125478820187gmail-typ">Action</span><span class="m_-3039719125478820187gmail-pln">)</span><span class="m_-3039719125478820187gmail-pun">.</span><span class="m_-3039719125478820187gmail-pln">

init([]) -> 
  erlang:send_after(</span><span class="m_-3039719125478820187gmail-lit">?INTERVAL,</span><span class="m_-3039719125478820187gmail-pln"> self()</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln"> trigger)</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">
  {ok</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln"> temple:new()}</span><span class="m_-3039719125478820187gmail-pun">.</span></code></pre>

<p>what I want to do is call this</p>

<pre class="m_-3039719125478820187gmail-lang-erlang m_-3039719125478820187gmail-prettyprint m_-3039719125478820187gmail-prettyprinted"><code><span class="m_-3039719125478820187gmail-pln">handle_call({fight}</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln"> </span><span class="m_-3039719125478820187gmail-typ">_From</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln"> </span><span class="m_-3039719125478820187gmail-typ">Temple</span><span class="m_-3039719125478820187gmail-pln">) ->
  </span><span class="m_-3039719125478820187gmail-typ">NewTemple</span><span class="m_-3039719125478820187gmail-pln"> = temple:fight(</span><span class="m_-3039719125478820187gmail-typ">Temple</span><span class="m_-3039719125478820187gmail-pln">)</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">
  {reply</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln"> </span><span class="m_-3039719125478820187gmail-typ">NewTemple</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln"> </span><span class="m_-3039719125478820187gmail-typ">NewTemple</span><span class="m_-3039719125478820187gmail-pln">}</span><span class="m_-3039719125478820187gmail-pun">;</span></code></pre>

<p>So I try</p>

<pre class="m_-3039719125478820187gmail-lang-erlang m_-3039719125478820187gmail-prettyprint m_-3039719125478820187gmail-prettyprinted"><code><span class="m_-3039719125478820187gmail-pln">handle_info(trigger</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln"> </span><span class="m_-3039719125478820187gmail-typ">_State</span><span class="m_-3039719125478820187gmail-pln">) ->
   land:action(self()</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln"> {fight})</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">
   erlang:send_after(</span><span class="m_-3039719125478820187gmail-lit">?INTERVAL,</span><span class="m_-3039719125478820187gmail-pln"> self()</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln"> trigger)</span><span class="m_-3039719125478820187gmail-pun">;</span></code></pre>

<p>but I get</p>

<pre class="m_-3039719125478820187gmail-lang-erlang m_-3039719125478820187gmail-prettyprint m_-3039719125478820187gmail-prettyprinted"><code><span class="m_-3039719125478820187gmail-pln">=</span><span class="m_-3039719125478820187gmail-typ">ERROR</span><span class="m_-3039719125478820187gmail-pln"> </span><span class="m_-3039719125478820187gmail-typ">REPORT</span><span class="m_-3039719125478820187gmail-pln">==== </span><span class="m_-3039719125478820187gmail-lit">4</span><span class="m_-3039719125478820187gmail-pln">-</span><span class="m_-3039719125478820187gmail-typ">Dec</span><span class="m_-3039719125478820187gmail-pln">-</span><span class="m_-3039719125478820187gmail-lit">2016</span><span class="m_-3039719125478820187gmail-pln">::</span><span class="m_-3039719125478820187gmail-lit">19</span><span class="m_-3039719125478820187gmail-pln">:</span><span class="m_-3039719125478820187gmail-lit">00</span><span class="m_-3039719125478820187gmail-pln">:</span><span class="m_-3039719125478820187gmail-lit">35</span><span class="m_-3039719125478820187gmail-pln"> ===
** </span><span class="m_-3039719125478820187gmail-typ">Generic</span><span class="m_-3039719125478820187gmail-pln"> server <</span><span class="m_-3039719125478820187gmail-lit">0.400</span><span class="m_-3039719125478820187gmail-pun">.</span><span class="m_-3039719125478820187gmail-lit">0</span><span class="m_-3039719125478820187gmail-pln">> terminating
** </span><span class="m_-3039719125478820187gmail-typ">Last</span><span class="m_-3039719125478820187gmail-pln"> message </span><span class="m_-3039719125478820187gmail-kwd">in</span><span class="m_-3039719125478820187gmail-pln"> was trigger
** </span><span class="m_-3039719125478820187gmail-typ">When</span><span class="m_-3039719125478820187gmail-pln"> </span><span class="m_-3039719125478820187gmail-typ">Server</span><span class="m_-3039719125478820187gmail-pln"> state == {{dict</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-lit">0</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-lit">16</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-lit">16</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-lit">8</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-lit">80</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-lit">48</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">
                               {[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun"><wbr>,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">
                                []}</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">
                               {{[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[<wbr>]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">
                                 []}}}</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">
                         []}
** </span><span class="m_-3039719125478820187gmail-typ">Reason</span><span class="m_-3039719125478820187gmail-pln"> for termination ==
** {function_clause</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[{land</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">termin<wbr>ate</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">
                           [{timeout</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">{gen_server</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-kwd">call</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[<</span><span class="m_-3039719125478820187gmail-lit">0<wbr>.400</span><span class="m_-3039719125478820187gmail-pun">.</span><span class="m_-3039719125478820187gmail-lit">0</span><span class="m_-3039719125478820187gmail-pln">></span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">{fight}]}}</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">
                            {{dict</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-lit">0</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-lit">16</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-lit">16</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-lit">8</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-lit">80</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-lit">48</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">
                                   {[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun"><wbr>,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">
                                    []</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]}</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">
                                   {{[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[<wbr>]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">
                                     []</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">[]}}}</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">
                             []}]</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">
                           [{file</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-str">"src/land.erl"</span><span class="m_-3039719125478820187gmail-pln">}</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-pln">{line</span><span class="m_-3039719125478820187gmail-pun">,</span><span class="m_-3039719125478820187gmail-lit">4<wbr>7</span><span class="m_-3039719125478820187gmail-pln">}]}<br><br><br></span></code></pre><pre class="m_-3039719125478820187gmail-lang-erlang m_-3039719125478820187gmail-prettyprint m_-3039719125478820187gmail-prettyprinted"><code><span class="m_-3039719125478820187gmail-pln">What am I missing here?<br></span></code></pre>
    </div></div></div>
<br>______________________________<wbr>_________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/<wbr>listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div>