Skip to content

Instantly share code, notes, and snippets.

@pabloh
Last active January 20, 2020 00:36
Show Gist options
  • Save pabloh/94c5dd1ead2ed8bc26dfbba600691f89 to your computer and use it in GitHub Desktop.
Save pabloh/94c5dd1ead2ed8bc26dfbba600691f89 to your computer and use it in GitHub Desktop.
# Set up pool
SharedPool = Concurrent::ThreadPoolExecutor.new(
:max_threads => 50,
:idletime => 10.minutes
)
# Worker thread
results = inputs.map do |input|
Concurrent::Future.execute_on(SharedPool) { DB.run_some_query(input) }
end.map(&:value!)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment