Reading from a FIFO, burning CPU

Elmar W. Hoefner elmar.hoefner at uibk.ac.at
Sat Jun 14 17:05:11 EDT 2003


Hi there!

I tried to continuously stream a FIFO into my python script.
I was successful so far, but the performance is not acceptable: If I start
the script, it eats 99% of my CPU cycles. Can anyone give me a hint how to
change this?
I did it this way:

fifo=open("/test_fifo", "r")
while 1:
        line=fifo.readline()
        # to stop the repeated printing of " '' " while nothing is in the fifo:
        if line != '': print line 

Anything better? I'm sure there is, any help is most appreciated! (Google
didn't help me, nor did the archives of this group...)

Thanks in advance,
Elmar

-- 
| Elmar W. Hoefner
| You can send me encrypted mail. Get my public GPG key from
| http://home.pages.at/oeller/files/pubkey.txt
| Fingerprint: B5D9 2544 A06A 6760 E16A  46BF 5A6B B7EF B530 08E2




More information about the Python-list mailing list