summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOmar Roth <omarroth@protonmail.com>2019-06-15 19:18:36 -0500
committerOmar Roth <omarroth@protonmail.com>2019-06-15 19:18:36 -0500
commit3be1c9261f12b44a8e84597bc59d1fe3d8504f87 (patch)
treef4111c19a78f60a4e6f6f48b6864287cec4f8a72 /src
parent38600b33477506aa99c3b3dab16b7d16f3842d84 (diff)
downloadinvidious-3be1c9261f12b44a8e84597bc59d1fe3d8504f87.tar.gz
invidious-3be1c9261f12b44a8e84597bc59d1fe3d8504f87.tar.bz2
invidious-3be1c9261f12b44a8e84597bc59d1fe3d8504f87.zip
Fix sleep in pull_top_videos
Diffstat (limited to 'src')
-rw-r--r--src/invidious.cr3
-rw-r--r--src/invidious/helpers/helpers.cr1
-rw-r--r--src/invidious/helpers/jobs.cr21
3 files changed, 19 insertions, 6 deletions
diff --git a/src/invidious.cr b/src/invidious.cr
index 1550bc8e..8d50f815 100644
--- a/src/invidious.cr
+++ b/src/invidious.cr
@@ -158,6 +158,7 @@ if config.statistics_enabled
}
sleep 1.minute
+ Fiber.yield
end
end
end
@@ -167,7 +168,6 @@ if config.top_enabled
spawn do
pull_top_videos(config, PG_DB) do |videos|
top_videos = videos
- sleep 1.minute
end
end
end
@@ -176,7 +176,6 @@ popular_videos = [] of ChannelVideo
spawn do
pull_popular_videos(PG_DB) do |videos|
popular_videos = videos
- sleep 1.minute
end
end
diff --git a/src/invidious/helpers/helpers.cr b/src/invidious/helpers/helpers.cr
index 41ebdaf5..aedd3053 100644
--- a/src/invidious/helpers/helpers.cr
+++ b/src/invidious/helpers/helpers.cr
@@ -703,6 +703,7 @@ def create_notification_stream(env, proxies, config, kemal_config, decrypt_funct
id += 1
sleep 1.minute
+ Fiber.yield
end
rescue ex
end
diff --git a/src/invidious/helpers/jobs.cr b/src/invidious/helpers/jobs.cr
index 941f0481..38494020 100644
--- a/src/invidious/helpers/jobs.cr
+++ b/src/invidious/helpers/jobs.cr
@@ -36,6 +36,7 @@ def refresh_channels(db, logger, config)
end
sleep 1.minute
+ Fiber.yield
end
end
@@ -112,6 +113,7 @@ def refresh_feeds(db, logger, config)
end
sleep 5.seconds
+ Fiber.yield
end
end
@@ -162,6 +164,7 @@ def subscribe_to_feeds(db, logger, key, config)
end
sleep 1.minute
+ Fiber.yield
end
end
@@ -174,12 +177,16 @@ def pull_top_videos(config, db)
begin
top = rank_videos(db, 40)
rescue ex
+ sleep 1.minute
+ Fiber.yield
+
next
end
- if top.size > 0
- args = arg_array(top)
- else
+ if top.size == 0
+ sleep 1.minute
+ Fiber.yield
+
next
end
@@ -194,7 +201,9 @@ def pull_top_videos(config, db)
end
yield videos
+
sleep 1.minute
+ Fiber.yield
end
end
@@ -206,7 +215,9 @@ def pull_popular_videos(db)
ORDER BY ucid, published DESC", as: ChannelVideo).sort_by { |video| video.published }.reverse
yield videos
+
sleep 1.minute
+ Fiber.yield
end
end
@@ -214,12 +225,13 @@ def update_decrypt_function
loop do
begin
decrypt_function = fetch_decrypt_function
+ yield decrypt_function
rescue ex
next
end
- yield decrypt_function
sleep 1.minute
+ Fiber.yield
end
end
@@ -234,5 +246,6 @@ def find_working_proxies(regions)
end
sleep 1.minute
+ Fiber.yield
end
end