Commit 2c6fe722 authored by James Lopez's avatar James Lopez

fix thread join issue

parent 6d09e946
...@@ -68,7 +68,6 @@ class FixNoValidatableImportUrl < ActiveRecord::Migration ...@@ -68,7 +68,6 @@ class FixNoValidatableImportUrl < ActiveRecord::Migration
end end
def process_invalid_import_urls def process_invalid_import_urls
@threads = []
batches = SqlBatches.new(query: "SELECT id, import_url FROM projects WHERE import_url IS NOT NULL") batches = SqlBatches.new(query: "SELECT id, import_url FROM projects WHERE import_url IS NOT NULL")
while batches.next? while batches.next?
...@@ -81,17 +80,16 @@ class FixNoValidatableImportUrl < ActiveRecord::Migration ...@@ -81,17 +80,16 @@ class FixNoValidatableImportUrl < ActiveRecord::Migration
process_batch(project_ids) process_batch(project_ids)
end end
@threads.each(&:join)
end end
def process_batch(project_ids) def process_batch(project_ids)
@threads << Thread.new do Thread.new do
begin begin
project_ids.each { |project_id| cleanup_import_url(project_id) } project_ids.each { |project_id| cleanup_import_url(project_id) }
ensure ensure
ActiveRecord::Base.connection.close ActiveRecord::Base.connection.close
end end
end end.join
end end
def valid_url?(url) def valid_url?(url)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment