在我的 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 分钟,但是如何以及在哪里呢?