[erlang-questions] Cannot use io:format() in a handle_call() callback in an application?

Attila Rajmund Nohl attila.r.nohl@REDACTED
Thu Jul 3 11:16:17 CEST 2014


Hello!

Try to trace into the io:format call to see what happens.

2014-07-03 9:04 GMT+02:00 Calle Dybedahl <calle@REDACTED>:
> Hi there.
>
> I've just run into a bit of behavior that I do not understand: if I have an
> io:format() in a handle_call, I get a timeout instead of a return from
> gen_server:call(), but only if the gen_server module was started as part of
> an application. I ran into it while trying to do something real, but it's
> easy enough to reproduce in a clean environment.
>
> So. I start with an application created with "rebar create-app appid=wtf"
> and "rebar create template=simplesrv srvid=wtf", and the wtf module added as
> a child of the supervisor. If I then do "application:start(wtf)." in a
> shell, "gen_server:call(wtf,something)." returns "ok" as expected. If I now
> add the single line "io:format("In handle_call.~n")," at the start of
> wtf:handle_call(), and try to run the same two commands, instead of "ok" I
> get a pause followed by:
>
> ** exception exit: {timeout,{gen_server,call,[wtf,something]}}
>      in function  gen_server:call/2 (gen_server.erl, line 182)
>
> I totally don't understand why this happens, and only when it was started
> with "application:start(wtf)". If I start either the wtf_sup or wtf modules
> manually, the io:format() runs and prints what it should without problems.
>
> I'm using Erlang 17.1 (installed with Homebrew) under OSX 10.9.
> --
> Calle Dybedahl -*- calle@REDACTED
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>



More information about the erlang-questions mailing list