v0.42.1 Rewrite and simplication of concurrent-ruby support

This commit is contained in:
David Sainty 2024-08-17 23:05:09 +10:00
parent ef50d344c9
commit 5a0e8a7d2b

View File

@ -1129,9 +1129,9 @@ class GossamerForumsImporter < ImportScripts::Base
password: "yxnh93Ybbz2Nm8#mp28zCVv", password: "yxnh93Ybbz2Nm8#mp28zCVv",
database: "slowtwitch" database: "slowtwitch"
) )
puts "PP 22 -- ${post_id}" puts "PP 22 -- #{post_id}"
begin ## begin
# Use connection pooling for PostgreSQL and synchronize access to shared resources # Use connection pooling for PostgreSQL and synchronize access to shared resources
ActiveRecord::Base.connection_pool.with_connection do ActiveRecord::Base.connection_pool.with_connection do
post_status = post_status(post_id) post_status = post_status(post_id)
@ -1145,15 +1145,15 @@ class GossamerForumsImporter < ImportScripts::Base
puts "Skipping post_id #{post_id}, already processed." puts "Skipping post_id #{post_id}, already processed."
end end
end end
rescue => e ## rescue => e
puts "Error processing post ID #{post_id}: #{e.message}" puts "Error processing post ID #{post_id}: #{e.message}"
sqlite_mutex.synchronize do sqlite_mutex.synchronize do
mark_post_as_failed(post_id) mark_post_as_failed(post_id)
end end
ensure ## ensure
# Ensure the MariaDB connection is closed after processing # Ensure the MariaDB connection is closed after processing
mysql_client.close if mysql_client mysql_client.close if mysql_client
end ## end
end end
end end