FIX: Limit concurrent `assets:precompile` to number of available cores.

This commit is contained in:
Guo Xiang Tan 2018-10-03 16:43:18 +08:00
parent 23b4ab9bf9
commit 13dde44c72
1 changed files with 3 additions and 1 deletions

View File

@ -151,9 +151,11 @@ def compress(from, to)
end
def concurrent?
executor = Concurrent::FixedThreadPool.new(Concurrent.processor_count)
if ENV["SPROCKETS_CONCURRENT"] == "1"
concurrent_compressors = []
yield(Proc.new { |&block| concurrent_compressors << Concurrent::Future.execute { block.call } })
yield(Proc.new { |&block| concurrent_compressors << Concurrent::Future.execute(executor: executor) { block.call } })
concurrent_compressors.each(&:wait!)
else
yield(Proc.new { |&block| block.call })