我有一個測試模塊,用於測試我的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}
我想知道是,我應該尋找什麼樣的代碼,這將導致我的董事會得到停止的原因?
完整的源是在這裏:[email protected]:QuantumProductions/tunnel.git
編輯:董事會包括本
handle_call(stop, _From, State) ->
{stop, normal, shutdown_ok, State};
handle_call(_, _, Board) ->
{reply, {error, unrecognized, Board}, Board}.
編輯:我最好的猜測是eunit
內創建自動終止其進程測試?
那麼我該如何終止我的過程沒有錯誤? – quantumpotato
我想你在Eunit測試中丟失了io進程,我推薦使用標準的sys調試,而不是io:格式。 http://erlang.org/doc/design_principles/spec_proc.html#debug – Pouriya
那麼,Eunit是否會告訴程序終止?當你說「失落的過程」 - 你的意思是Eunit殺死了它? – quantumpotato