Skip to content

Instantly share code, notes, and snippets.

@auxesis
Created August 6, 2012 13:38
Show Gist options
  • Select an option

  • Save auxesis/3274513 to your computer and use it in GitHub Desktop.

Select an option

Save auxesis/3274513 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'eventmachine'
require 'colorize'
EM.run do
@queue = EM::Queue.new
EM.add_periodic_timer(1) do
puts "[#{Time.now}] Running indexing...".green
sleep 4
@queue.push({:execution_time => rand(5)})
end
EM.add_periodic_timer(10) do
puts "[#{Time.now}] Serving results".blue
@queue.size.times do
@queue.pop { |msg| puts msg }
end
end
end
@auxesis
Copy link
Copy Markdown
Author

auxesis commented Aug 6, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment