Skip to content

Instantly share code, notes, and snippets.

@gouthamvel
Created January 10, 2012 06:41
Show Gist options
  • Save gouthamvel/1587471 to your computer and use it in GitHub Desktop.
Save gouthamvel/1587471 to your computer and use it in GitHub Desktop.
require 'eventmachine'
# Code adapted from EM's tests:
# https://github.com/eventmachine/eventmachine/blob/master/tests/test_processes.rb#L43
ls = ""
EM.run {
start_process = Proc.new do |id|
d = EM::DeferrableChildProcess.open( "/bin/bash -c 'slee 1 2> /tmp/err-em.log'" )
d.callback {|*args|
ls = " cmd completed for #{id}"+ args.inspect
puts ls
# start_process.call(id)
}
d.errback do |fail_status|
puts "cmd failed"
puts fail_status
end
end
start_process.call(1)
start_process.call(2)
start_process.call(3)
}
puts "All done."
puts ls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment