Class: Pwrake::GfarmPostprocess

Inherits:
Object
  • Object
show all
Defined in:
lib/pwrake/gfarm/gfarm_postprocess.rb

Instance Method Summary collapse

Constructor Details

#initialize(runner) ⇒ GfarmPostprocess

Returns a new instance of GfarmPostprocess.



5
6
7
8
9
10
# File 'lib/pwrake/gfarm/gfarm_postprocess.rb', line 5

def initialize(runner)
  @io = IO.popen('gfwhere-pipe','r+')
  @io.sync = true
  @hdl = Handler.new(runner,@io,@io)
  @chan = Channel.new(@hdl)
end

Instance Method Details

#closeObject



49
50
51
# File 'lib/pwrake/gfarm/gfarm_postprocess.rb', line 49

def close
  @io.close
end

#run(task_wrap) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/pwrake/gfarm/gfarm_postprocess.rb', line 12

def run(task_wrap)
  if !task_wrap.is_file_task?
    return []
  end
  filename = task_wrap.name
  begin
    @hdl.iow.puts(filename)
    @hdl.iow.flush
  rescue Errno::EPIPE
    Log.warn "GfarmPostprocess#run: Errno::EPIPE for #{filename}"
    return []
  end
  s = @chan.get_line
  if s.nil?
    raise "gfwhere: unexpected end"
  end
  s.chomp!
  if s != filename
    raise "gfwhere: file=#{filename}, result=#{s}"
  end
  while s = @chan.get_line
    s.chomp!
    case s
    when /^gfarm:\/\//
      next
    when /^Error:/
      a = []
      break
    else
      a = s.split(/\s+/)
      break
    end
  end
  Log.debug "Gfarm file=#{filename} nodes=#{a.join("|")}"
  a
end