我有一个测试模块来测试我的Table
模块。我的Table
模块在终止时调用:
terminate(_, State = {Board, Status, Players}) ->
gen_server:stop(Board),
...stopping other processes,
io:format("Table Terminating.~p~n", [State]),
ok.
这是我的代码中唯一会停止Board
进程的部分。
运行测试后,大约一分钟后我会得到这个:
=ERROR REPORT==== 21-Jul-2017::22:28:40 ===
** Generic server <0.92.0> terminating
** Last message in was []
** When Server state == [[{spawn,x,none},
{recent,x,none},
{empty,null,none},
{empty,null,none},
{empty,null,none}],
[{empty,null,none},
{empty,null,none},
{empty,null,none},
{ridge,null,none},
{empty,null,none}],
[{empty,null,none},
{empty,null,none},
{ridge,null,none},
{empty,null,none},
{empty,null,none}],
[{empty,null,none},
{ridge,null,none},
{empty,null,none},
{empty,null,none},
{empty,null,none}],
[{empty,null,none},
{empty,null,none},
{empty,null,none},
{empty,null,none},
{spawn,o,none}]]
** Reason for termination ==
** {terminated,[{io,format,
[<0.90.0>,"Board.~p~n",
[[[{spawn,x,none},
{recent,x,none},
{empty,null,none},
{empty,null,none},
{empty,null,none}],
[{empty,null,none},
{empty,null,none},
{empty,null,none},
{ridge,null,none},
{empty,null,none}],
[{empty,null,none},
{empty,null,none},
{ridge,null,none},
{empty,null,none},
{empty,null,none}],
[{empty,null,none},
{ridge,null,none},
{empty,null,none},
{empty,null,none},
{empty,null,none}],
[{empty,null,none},
{empty,null,none},
{empty,null,none},
{empty,null,none},
{spawn,o,none}]]]],
[]},
{board,terminate,2,[{file,"board.erl"},{line,319}]},
{gen_server,try_terminate,3,
[{file,"gen_server.erl"},{line,629}]},
{gen_server,terminate,7,[{file,"gen_server.erl"},{line,795}]},
{proc_lib,init_p_do_apply,3,
[{file,"proc_lib.erl"},{line,247}]}]
看起来Board
模块未正确终止。的Board
终止是这样的:
terminate(normal, State) ->
io:format("Board.~p~n", [State]),
ok.
我试图在一个独立的模块中重现这个b
:
-module(b).
-compile(export_all).
init([]) -> {ok, {1, 2}}.
terminate(_, State) ->
io:format("Table Terminating.~p~n", [State]),
ok.
code_change(_OldVsn, State, _Extra) ->
{ok, State}.
handle_cast(_, State) ->
{noreply, State}.
handle_info(Msg, State) ->
io:format("Unexpected message: ~p~n",[Msg]),
{noreply, State}.
go() ->
gen_server:start_link(?MODULE, [], []).
不成功:
4> {ok, B} = b:go().
{ok,<0.74.0>}
5> gen_server:stop(B).
Table Terminating.{1,2}
我想知道的是,我应该寻找什么样的代码会导致我的董事会得到** Reason for termination ==
** {terminated
停止的理由?
完整来源在这里:git@github.com:QuantumProductions/tunnel.git
编辑:董事会包括这个
handle_call(stop, _From, State) ->
{stop, normal, shutdown_ok, State};
handle_call(_, _, Board) ->
{reply, {error, unrecognized, Board}, Board}.
编辑:我最好的猜测是eunit
在其测试中创建的自动终止进程?