Re: Trying not to miss any output from a PROCESS

[email protected]
Newsgroups gmane.comp.lang.eiffel.smalleiffel
Message-ID <OFD12EB947.123CC046-ONC1256FFF.003FD059-C1256FFF.00414304@mpsa.com>
Hello,

> Does anybody can explain me my mistake(s)/misunderstanding(s) ?

Yes. There are two things to consider.

1- parallelism

Both processes work in parallel. It may be that the first read_line 
returns nothing if the process did not have a chance to run yet.

Your second try is better in that there is a loop that should ensure all 
the data is read. Alas, it is not so because end_of_input can get 
temporarily False if nothing is available, then be set back to True later.

Two solutions: either perform a p.wait before reading the data, and then 
the loop is even useless; either loop until p.finished and then 
p.output.end_of_input; which is simply equivalent to loop until not 
p.is_connected

2- the usual io algorithm

Your loop must BEGIN by a read_line in the from part; see the FAQ that 
explains the best way to code an io loop.
http://smarteiffel.loria.fr/man/SmartEiffelFAQ.html#Q17

Your loop should then look like:

        from
                p.output.read_line
        until
                not p.output.is_connected
        loop
                resultat.append(p.output.last_string)
                p.output.read_line
        end

Hope it helps! (and I hope it works, too) 8-)


Last words:

- I'll try to add a "sequencer" layer (using the JOB class and the 
lib/sequencer cluster) as I did for the lib/net cluster. It should help to 
simplify things. Maybe. Ideas and/or code are welcome.

- There are certainly bugs left in the library. Sorry about that.

- Of course, doc is missing. I'll add that too, eventually.


Best regards,
--
Cyril Adrian -- ALPLOG
@ PSA Peugeot Citroën, Sochaux, France
tél. +33 (0)3 81 33 48 76
fax +33 (0)3 81 33 16 06
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.