Pet*_*own 5 ruby ruby-on-rails
我有一个控制器:
class EventsController < ApplicationController
def index
begin
SystemTimer.timeout_after(10, CustomTimeoutError) do
sleep(11)
end
rescue CustomTimeoutError => e
# swallow
end
end
end
Run Code Online (Sandbox Code Playgroud)
出于某种原因,救援语句不要再追超时,而是它的冒泡一路攀升到顶部,堆栈跟踪被倾倒到控制台等使用defatult超时::错误有同样的效果.这只发生在生产上,而不是在我的开发机器上.就好像其他东西正在观察超时并在事件到达我的救援之前捕获它们.
产生的堆栈跟踪是这样的:
[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'
Run Code Online (Sandbox Code Playgroud)
您是如何声明自定义 CustomTimeoutError 类的?它是 Exception 还是 StandardError 的直接后代?当从 Exception 下降时,我确切地看到了这种行为,并养成了始终使我的错误类从 StandardError 下降的习惯。
| 归档时间: |
|
| 查看次数: |
289 次 |
| 最近记录: |