Reading from a FIFO, burning CPU

Elmar W. Hoefner elmar.hoefner at uibk.ac.at
Sun Jun 15 00:22:09 CEST 2003


Hi Terry!

Terry Reedy wrote:


 
> Like you told it to do.  Unless you have some other work to interleave
> with this process, this is no more wasteful than the CPU's or OS's own
> idle loop

Well, here it seems like ball and chain: even moving my mouse is exhausting,
but anyway...
> Simplest: try sleeping between readline() calls to free up CPU time
...this works perfectly now, thank you!

>>
>> 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

now:      
        if line == '': time.sleep(1)
        else: print line

Thanks for your help,
E.


-- 
| 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