Created
May 7, 2014 01:26
-
-
Save denishaskin/bd7ff6993c4bea728b73 to your computer and use it in GitHub Desktop.
naive threading
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_itineraries | |
threads = [] | |
trip_parts.each do |trip_part| | |
threads << Thread.new do | |
begin | |
trip_part.create_itineraries | |
ensure | |
begin | |
if (ActiveRecord::Base.connection && ActiveRecord::Base.connection.active?) | |
ActiveRecord::Base.connection.close | |
end | |
rescue Exception => e | |
Rails.logger.error e | |
raise e | |
end | |
end | |
end | |
end | |
threads.each do |t| | |
t.join | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment