Rename threads to fibers
The config and command line options haven't been changed.
This commit is contained in:
parent
eeeecf9763
commit
420ceffbb0
|
@ -7,9 +7,9 @@ class Invidious::Jobs::RefreshChannelsJob < Invidious::Jobs::BaseJob
|
||||||
end
|
end
|
||||||
|
|
||||||
def begin
|
def begin
|
||||||
max_threads = config.channel_threads
|
max_fibers = config.channel_threads
|
||||||
lim_threads = max_threads
|
lim_fibers = max_fibers
|
||||||
active_threads = 0
|
active_fibers = 0
|
||||||
active_channel = Channel(Bool).new
|
active_channel = Channel(Bool).new
|
||||||
backoff = 1.seconds
|
backoff = 1.seconds
|
||||||
|
|
||||||
|
@ -19,26 +19,26 @@ class Invidious::Jobs::RefreshChannelsJob < Invidious::Jobs::BaseJob
|
||||||
rs.each do
|
rs.each do
|
||||||
id = rs.read(String)
|
id = rs.read(String)
|
||||||
|
|
||||||
if active_threads >= lim_threads
|
if active_fibers >= lim_fibers
|
||||||
if active_channel.receive
|
if active_channel.receive
|
||||||
active_threads -= 1
|
active_fibers -= 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
active_threads += 1
|
active_fibers += 1
|
||||||
spawn do
|
spawn do
|
||||||
begin
|
begin
|
||||||
logger.trace("RefreshChannelsJob: Fetching channel #{id}")
|
logger.trace("RefreshChannelsJob: Fetching channel #{id}")
|
||||||
channel = fetch_channel(id, db, config.full_refresh)
|
channel = fetch_channel(id, db, config.full_refresh)
|
||||||
|
|
||||||
lim_threads = max_threads
|
lim_fibers = max_fibers
|
||||||
db.exec("UPDATE channels SET updated = $1, author = $2, deleted = false WHERE id = $3", Time.utc, channel.author, id)
|
db.exec("UPDATE channels SET updated = $1, author = $2, deleted = false WHERE id = $3", Time.utc, channel.author, id)
|
||||||
rescue ex
|
rescue ex
|
||||||
logger.error("RefreshChannelsJob: #{id} : #{ex.message}")
|
logger.error("RefreshChannelsJob: #{id} : #{ex.message}")
|
||||||
if ex.message == "Deleted or invalid channel"
|
if ex.message == "Deleted or invalid channel"
|
||||||
db.exec("UPDATE channels SET updated = $1, deleted = true WHERE id = $2", Time.utc, id)
|
db.exec("UPDATE channels SET updated = $1, deleted = true WHERE id = $2", Time.utc, id)
|
||||||
else
|
else
|
||||||
lim_threads = 1
|
lim_fibers = 1
|
||||||
logger.error("RefreshChannelsJob: #{id} : backing off for #{backoff}s")
|
logger.error("RefreshChannelsJob: #{id} : backing off for #{backoff}s")
|
||||||
sleep backoff
|
sleep backoff
|
||||||
if backoff < 1.days
|
if backoff < 1.days
|
||||||
|
|
|
@ -7,8 +7,8 @@ class Invidious::Jobs::RefreshFeedsJob < Invidious::Jobs::BaseJob
|
||||||
end
|
end
|
||||||
|
|
||||||
def begin
|
def begin
|
||||||
max_threads = config.feed_threads
|
max_fibers = config.feed_threads
|
||||||
active_threads = 0
|
active_fibers = 0
|
||||||
active_channel = Channel(Bool).new
|
active_channel = Channel(Bool).new
|
||||||
|
|
||||||
loop do
|
loop do
|
||||||
|
@ -17,13 +17,13 @@ class Invidious::Jobs::RefreshFeedsJob < Invidious::Jobs::BaseJob
|
||||||
email = rs.read(String)
|
email = rs.read(String)
|
||||||
view_name = "subscriptions_#{sha256(email)}"
|
view_name = "subscriptions_#{sha256(email)}"
|
||||||
|
|
||||||
if active_threads >= max_threads
|
if active_fibers >= max_fibers
|
||||||
if active_channel.receive
|
if active_channel.receive
|
||||||
active_threads -= 1
|
active_fibers -= 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
active_threads += 1
|
active_fibers += 1
|
||||||
spawn do
|
spawn do
|
||||||
begin
|
begin
|
||||||
# Drop outdated views
|
# Drop outdated views
|
||||||
|
|
|
@ -8,12 +8,12 @@ class Invidious::Jobs::SubscribeToFeedsJob < Invidious::Jobs::BaseJob
|
||||||
end
|
end
|
||||||
|
|
||||||
def begin
|
def begin
|
||||||
max_threads = 1
|
max_fibers = 1
|
||||||
if config.use_pubsub_feeds.is_a?(Int32)
|
if config.use_pubsub_feeds.is_a?(Int32)
|
||||||
max_threads = config.use_pubsub_feeds.as(Int32)
|
max_fibers = config.use_pubsub_feeds.as(Int32)
|
||||||
end
|
end
|
||||||
|
|
||||||
active_threads = 0
|
active_fibers = 0
|
||||||
active_channel = Channel(Bool).new
|
active_channel = Channel(Bool).new
|
||||||
|
|
||||||
loop do
|
loop do
|
||||||
|
@ -21,13 +21,13 @@ class Invidious::Jobs::SubscribeToFeedsJob < Invidious::Jobs::BaseJob
|
||||||
rs.each do
|
rs.each do
|
||||||
ucid = rs.read(String)
|
ucid = rs.read(String)
|
||||||
|
|
||||||
if active_threads >= max_threads.as(Int32)
|
if active_fibers >= max_fibers.as(Int32)
|
||||||
if active_channel.receive
|
if active_channel.receive
|
||||||
active_threads -= 1
|
active_fibers -= 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
active_threads += 1
|
active_fibers += 1
|
||||||
|
|
||||||
spawn do
|
spawn do
|
||||||
begin
|
begin
|
||||||
|
|
Loading…
Reference in New Issue