【发布时间】:2013-07-28 07:30:21
【问题描述】:
在我的 rails 应用程序中,我使用 open-uri 打开一个外部文件,这可能需要 10 分钟才能加载
例子:
dl_stream = open('http://wetten.overheid.nl/xml.php?regelingID=bwbr0020368')
现在,1 分钟后,Ruby 将抛出超时错误。我从 \net\protocol.rc 的源代码中收集到了这个:
@read_timeout = 60
def rbuf_fill
begin
@rbuf << @io.read_nonblock(BUFSIZE)
rescue IO::WaitReadable
if IO.select([@io], nil, nil, @read_timeout)
retry
else
raise Timeout::Error
end
rescue IO::WaitWritable
# OpenSSL::Buffering#read_nonblock may fail with IO::WaitWritable.
# http://www.openssl.org/support/faq.html#PROG10
if IO.select(nil, [@io], nil, @read_timeout)
retry
else
raise Timeout::Error
end
end
end
我猜我可以在我的应用设置中将此超时值设置为更适合我的情况的值,例如 15 分钟,但是如何以及在哪里?
【问题讨论】:
标签: ruby-on-rails ruby timeout