Mysterious closed stream (IOError) exception


#1

Hi, Sorry to keep bothering everybody with what are probably very
beginnerish questions. Thanks to everybody who has already helped me
out in
answering questions. This time I am complete mystified as to what is
going
own. The parse_input(input, output) function some how closes STDOUT.
Because "puts “71"” works fine but the "puts “100"” statement files with
a
closed stream exception. When the function is called input=ARGF and
output=$stdout. I am to much of a new person to be able to figure out
what
is causing the closed stream exception. All that I do know is that it
is
somewhere in this function and that this code works fine in the MRI. I
will
be happy to personally keep working on this code to figure out what is
broken if I can get some pointers on where and what to look for. Thanks
so
much in advance for all the help.

Josh

def parse_input(input, output)
current = []
data = []
data << current
print_lines = true
term = “\nFinished”.split(//).map { |c| c[0] }
term_length = term.size

old_sync = output.sync
output.sync = true

puts “71”
while line = input.gets
case line
when /^(Loaded suite|Started)/ then
print_lines = true
output.puts line
chars = []
while c = input.getc do
output.putc c
chars << c
tail = chars[-term_length…-1]
break if chars.size >= term_length and tail == term
end
output.puts input.gets # the rest of “Finished in…”
output.puts
next
when /^\s*$/, /^(?\s*\d+) (Failure|Error):/, /^\d+)/ then
print_lines = false
current = []
data << current
when /^Finished in \d/ then
print_lines = false
end
output.puts line if print_lines
current << line
end
output.sync = old_sync
data = data.reject { |o| o == ["\n"] or o.empty? }
footer = data.pop
puts “100”
return data, footer
end


#2

Josh M. wrote:

on this code to figure out what is broken if I can get some pointers on
where and what to look for. Thanks so much in advance for all the help.

Well keep trying to narrow it down, but the only thing that seems to
have any potential for causing this is the output.sync call. I’m a bit
confused myself though…

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email