<div dir="ltr">Not 100% sure, but you can catch the timeout with handle_info.<div>Somethig like </div><div>handle_info(timeout, State)-><br></div><div>  # do something .</div></div><div class="gmail_extra"><br clear="all">
<div>-Arun</div>
<br><br><div class="gmail_quote">On Tue, Oct 22, 2013 at 4:16 PM, Attila Rajmund Nohl <span dir="ltr"><<a href="mailto:attila.r.nohl@gmail.com" target="_blank">attila.r.nohl@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello!<br>
<br>
Exactly what would you like to achieve? If you don't expect serv2 to<br>
freeze, you can set the timeouts in the gen_server:calls to infinity.<br>
<br>
2013/10/22 Tien Le <<a href="mailto:letien83@gmail.com">letien83@gmail.com</a>>:<br>
<div><div class="h5">> Hi,<br>
><br>
> Please look at my sample code below. I have 2 gen_servers (serv1 and serv2).<br>
> serv1 start_link serv2, and traps exit.<br>
><br>
> %%% serv1:do/0 implementation: %%%<br>
> do() -><br>
>     gen_server:call(serv1, do).<br>
><br>
> handle_call(do, _From, State) -><br>
>     Result = serv2:do(),<br>
>     {reply, Result, State}.<br>
><br>
><br>
> %%% serv2:do/0 implementation: %%%<br>
> do() -><br>
>     gen_server:call(serv2, do).<br>
><br>
> handle_call(do, _From, State) -><br>
>     %% Something that takes time like timer:sleep/1<br>
>     Result = timer:sleep(5000),<br>
>     {reply, Result, State}.<br>
><br>
><br>
> As you can see that serv1's gen_server:call and serv2's gen_server:call have<br>
> the same timeout value (5000ms by default).<br>
><br>
> When I call serv1:do().<br>
> serv1 always terminates first due to timed out:<br>
><br>
> =CRASH REPORT==== 22-Oct-2013::10:26:38 ===<br>
>   crasher:<br>
>     initial call: serv1:init/1<br>
>     pid: <0.43.0><br>
>     registered_name: serv1<br>
>     exception exit: {timeout,{gen_server,call,[serv2,do]}}<br>
>       in function  gen_server:terminate/6 (gen_server.erl, line 747)<br>
> ...<br>
><br>
> One workaround is to increase the timeout of serv1 and serv2<br>
> gen_server:call/3, like this:<br>
> gen_server:call(serv1, do, 5020) => gen_server:call(serv2, do, 5010) =><br>
> timer:sleep(5000)<br>
><br>
> I would like to ask you if there's any nicer and synchronous way to handle<br>
> the timeout in this case?<br>
><br>
><br>
><br>
</div></div>> _______________________________________________<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" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
><br>
_______________________________________________<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" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div><br></div>