Class: EMPessimistic::DeferrableChildProcess

Inherits:
EventMachine::Connection
  • Object
show all
Includes:
EventMachine::Deferrable
Defined in:
lib/em_pessimistic/deferrable_child_process.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDeferrableChildProcess

Returns a new instance of DeferrableChildProcess.



32
33
34
35
36
# File 'lib/em_pessimistic/deferrable_child_process.rb', line 32

def initialize
  super
  @stdout = []
  @stderr = []
end

Class Method Details

.open(cmd) ⇒ Object



38
39
40
# File 'lib/em_pessimistic/deferrable_child_process.rb', line 38

def self.open(cmd)
  EMPessimistic.popen3(cmd, DeferrableChildProcess)
end

Instance Method Details

#receive_data(data) ⇒ Object



42
43
44
# File 'lib/em_pessimistic/deferrable_child_process.rb', line 42

def receive_data(data)
  @stdout << data
end

#receive_stderr(data) ⇒ Object



46
47
48
# File 'lib/em_pessimistic/deferrable_child_process.rb', line 46

def receive_stderr(data)
  @stderr << data
end

#unbindObject



50
51
52
53
54
55
56
57
# File 'lib/em_pessimistic/deferrable_child_process.rb', line 50

def unbind
  status = get_status
  if status.exitstatus != 0
    fail(@stderr.join.strip, status)
  else
    succeed(@stdout.join.strip, status)
  end
end