Interprocess comunication

J. Cliff Dyer jcd at sdf.lonestar.org
Thu Jun 7 12:30:40 EDT 2012


On Thu, 2012-06-07 at 16:04 +0000, Julio Sergio wrote:

> Up to this point it worked as expected. However, when I tryied with the methods 
> that write and read several lines, apparently the process got stalled:
> 
> ->>> fi.writelines(["uno\n","dos\n","tres\n"])
> ->>> fi.flush()
> ->>> s = fo.readlines()
> .
> .
> .

readlines() reads all the lines from the filehandle, but the filehandle
hasn't signalled that it is done writing lines, so fo is waiting until
fi is complete.  You either need to keep reading one line at a time, and
manually release control when there's nothing more to read, or you need
to do an fi.close() before you try to use fo.readlines().






More information about the Python-list mailing list