Unix Device File Emulation

Martin Blume mblume at freesurf.ch
Wed Apr 23 14:01:39 EDT 2008


"blaine" schrieb
> >
> > while 1:
> >  r = self.fifodev.readline()
> >  if r: print r
> >
> > According to my docs, readline() returns an empty 
> > string at the end of the file.
> > Also, you might want to sleep() between reads a 
> > little bit.
> >
> 
> Oh ok, that makes sense.  Hmm.  So do I not want to use 
> readline()? Or is there a way to do something like 
> 'block until the file is not empty'?
>

No, 
  while 1:
      r = self.fifodev.readline()
      if r: print r
      else: time.sleep(0.1)
is ok (note the "if r:" clause).

Martin






More information about the Python-list mailing list