mirror of
https://gitea.invidious.io/iv-org/invidious
synced 2024-12-23 07:26:39 +01:00
Add wait for empty connection pool
This commit is contained in:
parent
dfdeb02c7f
commit
60c618942f
@ -71,6 +71,10 @@ end
|
|||||||
|
|
||||||
def fetch_video(id)
|
def fetch_video(id)
|
||||||
# Grab connection from pool
|
# Grab connection from pool
|
||||||
|
while POOL.empty?
|
||||||
|
sleep rand(0..10).milliseconds
|
||||||
|
end
|
||||||
|
|
||||||
client = POOL.pop
|
client = POOL.pop
|
||||||
|
|
||||||
# client = HTTP::Client.new("www.youtube.com", 443, CONTEXT)
|
# client = HTTP::Client.new("www.youtube.com", 443, CONTEXT)
|
||||||
@ -196,6 +200,10 @@ end
|
|||||||
get "/search" do |env|
|
get "/search" do |env|
|
||||||
query = env.params.query["q"]
|
query = env.params.query["q"]
|
||||||
|
|
||||||
|
while POOL.empty?
|
||||||
|
sleep rand(0..10).milliseconds
|
||||||
|
end
|
||||||
|
|
||||||
client = POOL.pop
|
client = POOL.pop
|
||||||
|
|
||||||
html = client.get("https://www.youtube.com/results?q=#{URI.escape(query)}&page=1").body
|
html = client.get("https://www.youtube.com/results?q=#{URI.escape(query)}&page=1").body
|
||||||
|
Loading…
Reference in New Issue
Block a user