Add TIMEOUT parameter to swf_assets:manifests task

At this point, I've gone through all the assets, and the only ones
without manifests are:

1. The ones that truly have no manifest yet (that we know of)
2. The ones where execution happened to time out

I think the 5-second timeout is a very reasonable default for starting
the backfill, in a way that prioritizes moving forward; but now that we
have most things, I'd rather be able to re-run it with a more generous
timeout. So here we are!
This commit is contained in:
Emi Matchu 2023-11-11 11:04:53 -08:00
parent 3b59823fc4
commit 0845881aba

View file

@ -4,6 +4,8 @@ require 'async/http/internet/instance'
namespace :swf_assets do
desc "Backfill manifest_url for SwfAsset models"
task manifests: [:environment] do
timeout = ENV.fetch("TIMEOUT", "5").to_i
assets = SwfAsset.where(manifest_url: nil)
count = assets.count
puts "Found #{count} assets without manifests"
@ -32,7 +34,7 @@ namespace :swf_assets do
semaphore.async do |task|
manifest_url = nil
begin
task.with_timeout(5) do
task.with_timeout(timeout) do
manifest_url = infer_manifest_url(asset.url, internet)
end
rescue StandardError => error