puppeteer-ruby
puppeteer-ruby copied to clipboard
Use a global thread executor
Simple description about the feature
Introduce a Concurrent::FixedThreadPool for async tasks.
Usecase / Motivation
I've been using this library in a background job on Sidekiq. Sometimes the jobs hang and Sidekiq stops. I posted about this on StackOverflow.
One of the problems is I have a ridiculous number of threads (500+) on my Ruby process that's long running.
The source of those threads I believe is this library. It uses the default thread pools for concurrent operations.
See the following
500.times { Concurrent::Promise.execute { puts "Hi" } }
puts Thread.list.count # ~500
# Restart Ruby process and now try:
pool = Concurrent::FixedThreadPool.new(5)
500.times { Concurrent::Promise.execute(executor: pool) { puts "Hi" } }
puts Thread.list.count # ~13
This is far more efficient for the library.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.