fix error

This commit is contained in:
邱博亞 2022-02-23 13:57:42 +08:00
parent a73850d85d
commit 35a850b038
1 changed files with 6 additions and 6 deletions

View File

@ -31,19 +31,18 @@ class BulletinFeed
def generate_one_cache_timeout(startdt: nil,enddt: nil,dt: nil, base_url: nil, timeout: nil)
begin
if timeout.nil?
feed_cache = self.generate_one_cache(startdt: startdt,enddt: enddt,dt: dt,base_url: base_url)
feed_cache.content
feed_cache_content = self.generate_one_cache(startdt: startdt,enddt: enddt,dt: dt,base_url: base_url)
else
Timeout::timeout(timeout) do
feed_cache = nil
feed_cache_content = nil
thread = Thread.new do
feed_cache = self.generate_one_cache(startdt: startdt,enddt: enddt,dt: dt,base_url: base_url)
feed_cache_content = 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? && !thread.alive?
break if !feed_cache_content.nil? && !thread.alive?
end
feed_cache.content
feed_cache_content
end
end
rescue=> e
@ -189,6 +188,7 @@ class BulletinFeed
}.to_json
BulletinFeedCache.where(uid: uid,start: startdt,end: enddt,date: dt).destroy
feed_cache = BulletinFeedCache.create(uid: uid,content: anns,start: startdt,end: enddt,date: dt,invalid_date: invalid_date)
feed_cache.content
end
def self.smart_convertor(text,url)
doc = Nokogiri.HTML(text)