[erlang-questions] Gracefully Exit from state_timeout gen statem
Code Wiget
codewiget95@REDACTED
Wed Aug 15 22:31:21 CEST 2018
Thanks for the reply. I’m having an issue getting the full report because lager is truncating it. Will the stack trace help?
Stacktrace: [{gen_statem,parse_event_result,8,[{file,"gen_statem.erl"},{line,1267}]},{gen_statem,loop_event,6,[{file,"gen_statem.erl"},{line,1015}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]
But the process is exiting on this line:
> handle_event(state_timeout, _Msg, StateName, State) -> ?LOG(warning, "STATE TIMEOUT(State:~p)", [StateName], State),
> {stop, timeout}; <- This line
On Aug 15, 2018, 9:45 AM -0400, Raimo Niskanen <raimo+erlang-questions@REDACTED>, wrote:
> On Tue, Aug 07, 2018 at 03:05:08PM -0400, Code Wiget wrote:
> > Would like to update this to say that I’m using {state_timeout, 2000, timeout}, rather than {state_timeout, 2000}
> >
> > On Aug 7, 2018, 2:29 PM -0400, Code Wiget <codewiget95@REDACTED>, wrote:
> > > Hi everyone,
> > >
> > > How do you gracefully exit from a state_timeout in a gen_statem? Generally, for a gen_statem, I can return “stop” or {stop, Reason} from a state function and the statem will terminate. However, if I use a state timeout method, returned from init:
> > >
> > > > {ok, new_state, State, {state_timeout, 2000}}
> > >
> > > The new_state(state_timeout, Info, State) method is called after 2000. Returning “stop” from this given an error…:
> > >
> > > > 18:22:33.039 [error] <0.576.0> : Lager event handler error_logger_lager_h exited with reason {'EXIT',{{badmatch,[smdpp_proxy,{state_timeout,timeout},[{data,[{"State",{awaiting_
>
> Can you post the whole printout?
> The truncation hides where the process has crashed.
>
> > > >
> > > What can I return from this function to gracefully exit? Can this be done with state_timeout? If this is an obvious question, please point me in the right direction. The documentation here:http://erlang.org/doc/man/gen_statem.html doesn’t seem to mention any return from the state_timeout.
> > >
> > > Thanks!
> > >
> > >
>
> --
>
> / Raimo Niskanen, Erlang/OTP, Ericsson AB
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20180815/96b854e4/attachment.htm>
More information about the erlang-questions
mailing list