[erlang-questions] Gracefully Exit from state_timeout gen statem

Code Wiget codewiget95@REDACTED
Tue Aug 7 20:29:39 CEST 2018


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!


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20180807/12b41ed9/attachment.htm>


More information about the erlang-questions mailing list