Try catch not works with Genserver call timeout option.

閲覧: 1,668 回
最初の未読メッセージにスキップ

Narcissus Emi

未読、
2015/06/24 15:20:592015/06/24
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

未読、
2015/06/24 15:25:212015/06/24
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

未読、
2015/06/25 5:22:112015/06/25
To: elixir-l...@googlegroups.com
Arrrrrr,thx very much XD

在 2015年6月25日星期四 UTC+8上午3:20:59,Narcissus Emi写道:
全員に返信
投稿者に返信
転送
新着メール 0 件