[erlang-questions] Gracefully Exit from state_timeout gen statem

Raimo Niskanen raimo+erlang-questions@REDACTED
Wed Aug 15 15:01:30 CEST 2018


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_
> > >
> > 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!
> >
> >

Which Erlang/OTP version is this?

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB



More information about the erlang-questions mailing list