Skip to content

Instantly share code, notes, and snippets.

@jwo
Created May 22, 2013 18:18
Show Gist options
  • Save jwo/5629696 to your computer and use it in GitHub Desktop.
Save jwo/5629696 to your computer and use it in GitHub Desktop.
Rails app with celluloid -- http://stackoverflow.com/questions/16694102/
Started GET "/pages/create" for 127.0.0.1 at 2013-05-22 13:15:01 -0500
Processing by PagesController#create as HTML
About to sleep 2013-05-22 13:15:01 -0500
Rendered pages/create.html.erb within layouts/application (0.5ms)
Completed 200 OK in 8ms (Views: 5.3ms | ActiveRecord: 0.0ms)
Awake! 2013-05-22 13:15:11 -0500
class PagesController < ApplicationController
def root
end
def create
SleepyWorker.new.async.sleep_for(10)
end
end
class SleepyWorker
include Celluloid
def sleep_for(seconds=5)
puts "About to sleep #{Time.now}"
sleep seconds
puts "Awake! #{Time.now}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment