From 0845881abaee8fa820b5568695c2afdf3ce5ba74 Mon Sep 17 00:00:00 2001 From: Matchu Date: Sat, 11 Nov 2023 11:04:53 -0800 Subject: [PATCH] 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! --- lib/tasks/swf_assets.rake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/tasks/swf_assets.rake b/lib/tasks/swf_assets.rake index 309833a6..66f25c87 100644 --- a/lib/tasks/swf_assets.rake +++ b/lib/tasks/swf_assets.rake @@ -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