Module: RightScale::StatusHandler
- Defined in:
- lib/right_popen/linux/right_popen.rb
Instance Method Summary collapse
- #drain_and_close ⇒ Object
- #initialize(file_handle) ⇒ Object
- #receive_data(data) ⇒ Object
- #unbind ⇒ Object
Instance Method Details
#drain_and_close ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/right_popen/linux/right_popen.rb', line 52 def drain_and_close begin while ready = IO.select([@handle], nil, nil, 0) break if @handle.eof? data = @handle.readpartial(4096) receive_data(data) end rescue Errno::EBADF, EOFError, IOError end close_connection end |
#initialize(file_handle) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/right_popen/linux/right_popen.rb', line 39 def initialize(file_handle) # Voodoo to make sure that Ruby doesn't gc the file handle # (closing the stream) before we're done with it. No, oddly # enough EventMachine is not good about holding on to this # itself. @handle = file_handle @data = "" end |
#receive_data(data) ⇒ Object
48 49 50 |
# File 'lib/right_popen/linux/right_popen.rb', line 48 def receive_data(data) @data << data end |
#unbind ⇒ Object
64 65 66 67 68 69 |
# File 'lib/right_popen/linux/right_popen.rb', line 64 def unbind if @data.size > 0 e = Marshal.load @data raise (Exception === e ? e : "unknown failure: saw #{e} on status channel") end end |