"blaine" schrieb > > # Fake Nokia Screen Emulator > import sys, os > > class nokia_fkscrn: > def __init__(self, file): > if not os.path.exists(file): > os.mkfifo(file) > self.fifodev = open(file, 'r') > def read(self): > while 1: > r = self.fifodev.readline() > print r > > nokia = nokia_fkscrn('dev.file') > nokia.read() > > This works at first, but when I write to the 'dev.file' > for the first time, the text is displayed as intended, > but then the program just keeps spitting out blank lines. > I can continue to write to the file > (using echo 'test\n' > dev.file) > and this shows up in my output, but amist a giant mass > of scrolling blank lines. This also causes my CPU > usage to shoot up to 100%. > > Any ideas? This is OS X 10.4 >
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. IMHO. HTH. Martin -- http://mail.python.org/mailman/listinfo/python-list