Try catch not works with Genserver call timeout option.

1,719 views
Skip to first unread message

Narcissus Emi

unread,
Jun 24, 2015, 3:20:59 PM6/24/15
to elixir-l...@googlegroups.com
This is a piece of code inside of a GenServer implementation, and this call is a async call(which it returns a no_reply at handle_call block), I would like it to return me back a :no_reply value after the timeout, but it indeed keep crashes my process.

  def call(exchange,routing_key,content) do
    try do 
      :gen_server.call(__MODULE__,{:call,{exchange,routing_key,content}},1000)
    rescue
      e ->
        IO.puts "get #{inspect e}"
        :no_reply
    end
  end

here is a snapshot I'm working with AMQP queue, I would expect after the timeout it should yield me back :noreply, and here is the crash info.
** (exit) exited in: :gen_server.call(MessageDispatcher, {:call, {"Event", "NewMessage", "test"}}, 1000)
    ** (EXIT) time out
             (stdlib) gen_server.erl:190: :gen_server.call/3
    (generic_gateway) lib/wechat_message_callback/msg/msg_callback.ex:24: MessageDispatcher.call/3
iex(4)>

José Valim

unread,
Jun 24, 2015, 3:25:21 PM6/24/15
to elixir-l...@googlegroups.com



José Valim
Skype: jv.ptec
Founder and Director of R&D

--
You received this message because you are subscribed to the Google Groups "elixir-lang-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-ta...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-talk/2938d4f8-3873-442e-a7c2-8f25cde8793c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Narcissus Emi

unread,
Jun 25, 2015, 5:22:11 AM6/25/15
to elixir-l...@googlegroups.com
Arrrrrr,thx very much XD

在 2015年6月25日星期四 UTC+8上午3:20:59,Narcissus Emi写道:
Reply all
Reply to author
Forward
0 new messages