[erlang-questions] can flush the shell but can't receive from it

Imants Cekusins <>
Mon Nov 17 22:44:59 CET 2014


Why not try to send / receive { A, B } instead of A, B

?
On 17 Nov 2014 22:38, <> wrote:

> Hi,
>
> I have the simplest of applications that consists of just the skeleton
> gen_server, registered locally as "server", with one callback implemented:
>
>   handle_info({From, A, B}, State) ->
>     From ! {self(), A + B},
>     {noreply, State};
>
> i.e. a simple adder
>
> The supervisor is the skeleton one_for_one supervisor. The application,
> app, the skeleton application.
>
> Here is what I do:
>
> 7> application:start(app).
> ok
> 8> server ! {self(), 1, 2}.
> {<0.32.0>,1,2}
> 9> receive X -> X end.
> {<0.62.0>,3}
> 10> server ! {self(), a, b}.
>
> =ERROR REPORT==== 17-Nov-2014::22:18:42 ===
> ** Generic server server terminating
> ** Last message in was {<0.32.0>,a,b}
> ** When Server state == {state}
> ** Reason for termination ==
> ** {badarith,[{server,handle_info,2,[{file,"server.erl"},{line,98}]},
>               {gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,
> 599}]},
>               {proc_lib,init_p_do_apply,3,
>                         [{file,"proc_lib.erl"},{line,239}]}]}
> {<0.32.0>,a,b}
> 11> server ! {self(), 3, 4}.
> {<0.32.0>,3,4}
> 12> receive X -> X end.
>
> and here the shell blocks.
> The message ({<0.67.0>,7}) is in the shell's mailbox alright. I can see it
> by running observer.
>
> If, instead of receive X -> X end, I do a flush(), the message _is_
> flushed.
>
> It is reproducible on R 17, R15B01, on linux and on windows.
>
> What am I doing wrong?
>
> Thanks and best regards
> Arif
>
>
>
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20141117/2c4c7049/attachment.html>


More information about the erlang-questions mailing list