Unix Device File Emulation
blaine
frikker at gmail.com
Wed Apr 23 14:11:46 EDT 2008
On Apr 23, 2:01 pm, "Martin Blume" <mbl... at freesurf.ch> wrote:
> "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
Beautiful! Thanks Martin!
More information about the Python-list
mailing list