gen_statem and returning {next_event, internal, astate} from init/1

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

gen_statem and returning {next_event, internal, astate} from init/1

bengt e
Greetings,

Running tests on a gen_statem application they all fail. Directly after callback init/1. I see
** Reason for termination = error:{bad_action_from_state_function,
                                      {next_events,internal,reconnect}}
This is init, BTW:
init() -> {ok, connect, #{}, {next_event, internal, reconnect}}.

Looking in gen_statem.erl the calls after init() are (simplified):
enter(), where we add a new variable TransOpts (map, is empty) 
loop_event_actions()
loop_event_actions_list()
parse_actions(), where if TransOpts is a map, we add a new variable StateCall (boolean, is false)
parse_actions()
parse_actions_next_event(), where StateCall must be true to actually do this.

Is there a way to persuade gen_statem to do parse_actions_next_event(), even if TransOpts is a map?

Erlang OTP 20.3
Ubuntu 18.04.1 LTS


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: gen_statem and returning {next_event, internal, astate} from init/1

Andrew Thompson-2
On Thu, Oct 18, 2018 at 03:00:57PM +0200, bengt e wrote:
> Greetings,
>
> Running tests on a gen_statem application they all fail. Directly after
> callback init/1. I see
> ** Reason for termination = error:{bad_action_from_state_function,
>                                       {next_events,internal,reconnect}}
> This is init, BTW:
> init() -> {ok, connect, #{}, {next_event, internal, reconnect}}.
>

I believe this will work on OTP 21.1, it might be worth trying it there.

Andrew
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: gen_statem and returning {next_event, internal, astate} from init/1

bengt e
Upgrading to 20.3.8.6 solved it.

On Thu, Oct 18, 2018 at 4:54 PM Andrew Thompson <[hidden email]> wrote:
On Thu, Oct 18, 2018 at 03:00:57PM +0200, bengt e wrote:
> Greetings,
>
> Running tests on a gen_statem application they all fail. Directly after
> callback init/1. I see
> ** Reason for termination = error:{bad_action_from_state_function,
>                                       {next_events,internal,reconnect}}
> This is init, BTW:
> init() -> {ok, connect, #{}, {next_event, internal, reconnect}}.
>

I believe this will work on OTP 21.1, it might be worth trying it there.

Andrew
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions