LoginSignup
2
1

More than 5 years have passed since last update.

herokuで1dynoで非同期処理を行う

Posted at

EventMachineを使います。

app.rb
get '/async' do
  operation = proc {
    p 'operation started!'
    10.times do |i|
      puts "#{i} times Hello, Async!"
      sleep 1
    end
  }
  callback = proc {|result|
    p 'operation finished!'
  }
  EventMachine.defer(operation, callback)
  redirect '/'
end

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1