我有一个控制器:
class EventsController < ApplicationController
def index
begin
SystemTimer.timeout_after(10, CustomTimeoutError) do
sleep(11)
end
rescue CustomTimeoutError => e
# swallow
end
end
end
由于某种原因,救援声明没有捕获超时但是它一直冒泡到顶部,堆栈跟踪被转储到控制台等。使用defatult Timeout :: Error具有相同的效果。这只发生在生产上,而不是在我的开发机器上。就好像其他东西正在观察超时并在事件到达我的救援之前捕获它们。
产生的堆栈跟踪是:
[GEM_ROOT]/gems/SystemTimer-1.2/lib/system_timer/concurrent_timer_pool.rb:63:in `read_reply'
vendor/gems/redis-1.0.4/lib/redis/client.rb:444:in `process_command'
vendor/gems/redis-1.0.4/lib/redis/client.rb:442:in `map'
vendor/gems/redis-1.0.4/lib/redis/client.rb:442:in `process_command'
vendor/gems/redis-1.0.4/lib/redis/client.rb:431:in `raw_call_command'
vendor/gems/redis-1.0.4/lib/redis/client.rb:452:in `call'
vendor/gems/redis-1.0.4/lib/redis/client.rb:452:in `maybe_lock'
vendor/gems/redis-1.0.4/lib/redis/client.rb:428:in `raw_call_command'
vendor/gems/redis-1.0.4/lib/redis/client.rb:332:in `call_command'
vendor/gems/redis-1.0.4/lib/redis/client.rb:381:in `method_missing'
vendor/gems/ohm-0.0.35/lib/ohm/collection.rb:179:in `size'
vendor/gems/ohm-0.0.35/lib/ohm/collection.rb:65:in `empty?'
vendor/gems/ohm-0.0.35/lib/ohm/collection.rb:33:in `sort'
vendor/gems/ohm-0.0.35/lib/ohm/collection.rb:48:in `first'
vendor/gems/ohm-0.0.35/lib/ohm.rb:129:in `first'
lib/twitter_helper.rb:58:in `get_twitter_searches'
lib/twitter_helper.rb:57:in `each'
lib/twitter_helper.rb:57:in `get_twitter_searches'
lib/twitter_helper.rb:100:in `get_twitter_searches_or_messages'
app/controllers/events_controller.rb:66:in `show'
[GEM_ROOT]/gems/SystemTimer-1.2/lib/system_timer.rb:56:in `timeout_after'
app/controllers/events_controller.rb:65:in `show'
vendor/rails/actionpack/lib/action_controller/base.rb:1331:in `send'
答案 0 :(得分:2)
您是如何声明自定义CustomTimeoutError类的?它是Exception或StandardError的直接后代吗?我从Exception下降时看到了这种行为,并且总是让我的错误类从StandardError继续下去。