Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
threads << Thread.new do ActiveRecord::Base.connection_pool.with_connection do
# needed because otherwise the connection pool can run
# out of connections
t = Thread.current
t[:variable_name] = Model.find_by(column: data)
end
end
joined_threads = threads.map &:join
# do something with the thread local variable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.