Created
March 6, 2009 04:50
-
-
Save careo/74763 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 'rubygems' | |
| require 'eventmachine' | |
| module EventMachine | |
| module ChildProcess | |
| def initialize | |
| @buffer = [] | |
| end | |
| def receive_data data | |
| puts "------" | |
| puts data | |
| puts "------" | |
| end | |
| def unbind | |
| p get_status | |
| p get_status.exitstatus | |
| end | |
| end | |
| def EM.spawn cmd, &cb | |
| EM.popen cmd, ChildProcess do |c| | |
| p c | |
| end | |
| end | |
| end | |
| EM.run{ | |
| EM.add_periodic_timer(1) { | |
| print "." | |
| } | |
| EM.spawn('ruby long-running-child.rb') do |results| | |
| puts results | |
| end | |
| EM.add_timer(15) { | |
| EM.stop | |
| } | |
| } |
This file contains hidden or 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 'rubygems' | |
| require 'eventmachine' | |
| EM.run { | |
| EM.add_periodic_timer(1) { | |
| puts "tick" | |
| } | |
| EM.add_timer(10) { | |
| puts "done" | |
| EM.stop | |
| } | |
| } |
This file contains hidden or 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
| #<#<Class:0x500898>:0x500618 @signature="8e0ebeef062bf970d9f5271429d793233", @buffer=[]> | |
| .........------ | |
| tick | |
| tick | |
| tick | |
| tick | |
| tick | |
| tick | |
| tick | |
| tick | |
| tick | |
| done | |
| ------ | |
| #<Process::Status: pid=12937,exited(0)> | |
| 0 | |
| .... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment