Invidious is an alternative front-end to YouTube
Rename threads to fibers
saltycrys420ceffbb0ce
diff --git a/src/invidious/jobs/refresh_channels_job.cr b/src/invidious/jobs/refresh_channels_job.crindex bbf55ff3..f4dee063 100644--- a/src/invidious/jobs/refresh_channels_job.cr+++ b/src/invidious/jobs/refresh_channels_job.cr@@ -7,9 +7,9 @@ class Invidious::Jobs::RefreshChannelsJob < Invidious::Jobs::BaseJobenddef begin- max_threads = config.channel_threads- lim_threads = max_threads- active_threads = 0+ max_fibers = config.channel_threads+ lim_fibers = max_fibers+ active_fibers = 0active_channel = Channel(Bool).newbackoff = 1.seconds@@ -19,26 +19,26 @@ class Invidious::Jobs::RefreshChannelsJob < Invidious::Jobs::BaseJobrs.each doid = rs.read(String)- if active_threads >= lim_threads+ if active_fibers >= lim_fibersif active_channel.receive- active_threads -= 1+ active_fibers -= 1endend- active_threads += 1+ active_fibers += 1spawn dobeginlogger.trace("RefreshChannelsJob: Fetching channel #{id}")channel = fetch_channel(id, db, config.full_refresh)- lim_threads = max_threads+ lim_fibers = max_fibersdb.exec("UPDATE channels SET updated = $1, author = $2, deleted = false WHERE id = $3", Time.utc, channel.author, id)rescue exlogger.error("RefreshChannelsJob: #{id} : #{ex.message}")if ex.message == "Deleted or invalid channel"db.exec("UPDATE channels SET updated = $1, deleted = true WHERE id = $2", Time.utc, id)else- lim_threads = 1+ lim_fibers = 1logger.error("RefreshChannelsJob: #{id} : backing off for #{backoff}s")sleep backoffif backoff < 1.daysdiff --git a/src/invidious/jobs/refresh_feeds_job.cr b/src/invidious/jobs/refresh_feeds_job.crindex 5dd47639..208569b8 100644--- a/src/invidious/jobs/refresh_feeds_job.cr+++ b/src/invidious/jobs/refresh_feeds_job.cr@@ -7,8 +7,8 @@ class Invidious::Jobs::RefreshFeedsJob < Invidious::Jobs::BaseJobenddef begin- max_threads = config.feed_threads- active_threads = 0+ max_fibers = config.feed_threads+ active_fibers = 0active_channel = Channel(Bool).newloop do@@ -17,13 +17,13 @@ class Invidious::Jobs::RefreshFeedsJob < Invidious::Jobs::BaseJobemail = rs.read(String)view_name = "subscriptions_#{sha256(email)}"- if active_threads >= max_threads+ if active_fibers >= max_fibersif active_channel.receive- active_threads -= 1+ active_fibers -= 1endend- active_threads += 1+ active_fibers += 1spawn dobegin# Drop outdated viewsdiff --git a/src/invidious/jobs/subscribe_to_feeds_job.cr b/src/invidious/jobs/subscribe_to_feeds_job.crindex 3bb31299..2255730d 100644--- a/src/invidious/jobs/subscribe_to_feeds_job.cr+++ b/src/invidious/jobs/subscribe_to_feeds_job.cr@@ -8,12 +8,12 @@ class Invidious::Jobs::SubscribeToFeedsJob < Invidious::Jobs::BaseJobenddef begin- max_threads = 1+ max_fibers = 1if config.use_pubsub_feeds.is_a?(Int32)- max_threads = config.use_pubsub_feeds.as(Int32)+ max_fibers = config.use_pubsub_feeds.as(Int32)end- active_threads = 0+ active_fibers = 0active_channel = Channel(Bool).newloop do@@ -21,13 +21,13 @@ class Invidious::Jobs::SubscribeToFeedsJob < Invidious::Jobs::BaseJobrs.each doucid = rs.read(String)- if active_threads >= max_threads.as(Int32)+ if active_fibers >= max_fibers.as(Int32)if active_channel.receive- active_threads -= 1+ active_fibers -= 1endend- active_threads += 1+ active_fibers += 1spawn dobegin