Created
January 10, 2012 06:41
-
-
Save gouthamvel/1587471 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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