Net::SFTP's upload
method (without bang) operates asynchronously, i.e. in parallel.
From the docs:
Or, if you have multiple uploads that you want to run in parallel, you can employ the
wait
method of the returned object:uploads = %w(file1 file2 file3).map { |f| sftp.upload(f, "remote/#{f}") } uploads.each { |u| u.wait }