[erlang-questions] gen_server call "failure"

Edwin Fine erlang-questions_efine@REDACTED
Tue Mar 31 02:20:54 CEST 2009


On Fri, Mar 27, 2009 at 4:00 PM, tsuraan <tsuraan@REDACTED> wrote:

> According to the documentation, a gen_server call function may fail if
> the process in question exits before the call returns.  What exactly
> does fail mean in this context?  Does gen_server:call raise an
> exception?  If so, is the format of that exception documented
> anywhere?


I assume you mean the sentence in the gen_server ref man that states, "The
call may fail for several reasons, including timeout and the called
gen_server dying before or during the call. "

The answer seems to be that if the gen_server dies before the call is
complete, the calling function receives an exit:

{'EXIT', {Reason, {gen_server, call, [Module, Function]}}}

I played around with some throwaway code to get the above results. It's
attached if you're interested.

(ed17404@REDACTED)26>
gscaller:run().
[gscaller:<0.133.0>:{1238,457700,76877}] Calling
slow_call().
<0.134.0>

[gsfail:<0.131.0>:{1238,457700,76951}] Received slow call, starting
wait.
[gscaller:<0.134.0>:{1238,457701,78177}] Killing
<0.131.0>.
[gscaller:<0.133.0>:{1238,457701,78274}] slow_call() returned, result =
{'EXIT',

{killed,

{gen_server,

call,

[gsfail,

slow_call]}}}
** exception error:
killed


Ed


> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090330/d3e86453/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gsfail.erl
Type: text/x-erlang
Size: 4204 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090330/d3e86453/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gscaller.erl
Type: text/x-erlang
Size: 673 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090330/d3e86453/attachment-0001.bin>


More information about the erlang-questions mailing list