[erlang-questions] Diagnosing gen_server call timeouts
Roger Lipscombe
roger@REDACTED
Fri Sep 20 13:57:04 CEST 2019
Er, so I neglected to mention that the gen_server is remote (same
host, different node), so process_info doesn't work :(
On Fri, 20 Sep 2019 at 01:45, Max Lapshin <max.lapshin@REDACTED> wrote:
>
> Copy paste from our video_frame.erl:
>
>
> send_frame(Stream, #video_frame{content = Content, codec = Codec, flavor = Flavor, dts = DTS} = Frame, SourceTag) when is_pid(Stream) ->
> Frame1 = case SourceTag of
> undefined -> Frame;
> _ -> Frame#video_frame{source = SourceTag}
> end,
> try gen_server:call(Stream, Frame1)
> catch
> exit:{normal, _} ->
> {error, stopped};
> exit:{noproc, _} ->
> {error, stopped};
> exit:{shutdown, _} ->
> {error, stopped};
> exit:{timeout, _}:Stack ->
> Dict = case process_info(Stream, dictionary) of
> {dictionary, Dict_} -> Dict_;
> undefined -> []
> end,
> RemoteStack = process_info(Stream, current_stacktrace),
> Name = case proplists:get_value(name, Dict, <<"dead stream">>) of
> N when is_binary(N) -> N;
> N when is_atom(N) -> N;
> N -> iolist_to_binary(io_lib:format("~p", [N]))
> end,
> Status = proplists:get_value(status, Dict),
> case Status of
> S when S == starting_transcoder -> ok;
> _ -> events:error("failed to send frame ~p,~p,~p,~p, source_tag=~p to ~s (~p) in status ~p\n~p\nremote stack:\n~p", [
> Content, Codec, Flavor, round(DTS), Frame1#video_frame.source,
> Name, Stream, Status, Stack, RemoteStack])
> end,
> % [io:format("~10.. s: ~p~n", [K,V]) || {K,V} <- process_info(Stream)]
> {error, timeout}
> end.
>
>
>
> this code is helping us for years. You should remove video specific stuff.
More information about the erlang-questions
mailing list