fix error

This commit is contained in:
邱博亞 2021-11-18 10:30:25 +08:00
parent 6807b93489
commit 4da5940753
1 changed files with 15 additions and 11 deletions

View File

@ -29,19 +29,23 @@ class BulletinFeed
end end
end end
def generate_one_cache_timeout(startdt: nil,enddt: nil,dt: nil, base_url: nil, timeout: nil) def generate_one_cache_timeout(startdt: nil,enddt: nil,dt: nil, base_url: nil, timeout: nil)
timeout = 100000 if timeout.nil?
begin begin
Timeout::timeout(timeout) { if timeout.nil?
feed_cache = nil feed_cache = self.generate_one_cache(startdt: startdt,enddt: enddt,dt: dt,base_url: base_url)
Thread.new do
feed_cache = self.generate_one_cache(startdt: startdt,enddt: enddt,dt: dt,base_url: base_url)
end
(1..(timeout.to_i+1)).each do
sleep(1)
break if !feed_cache.nil?
end
feed_cache.content feed_cache.content
} else
Timeout::timeout(timeout) {
feed_cache = nil
Thread.new do
feed_cache = self.generate_one_cache(startdt: startdt,enddt: enddt,dt: dt,base_url: base_url)
end
(1..(timeout.to_i+1)).each do
sleep(1)
break if !feed_cache.nil?
end
feed_cache.content
}
end
rescue=> e rescue=> e
puts [e,e.backtrace] puts [e,e.backtrace]
"" ""