File Polling (Rereading)

Diez B. Roggisch deets.nospaaam at web.de
Thu Oct 21 07:20:29 EDT 2004


Daniel Mueller wrote:

> Hello Fellow Python Programmers,
> 
> I have the following problem:
> 
> i want to read the content of a file every 10 seconds. now what is the
> best funktion to do that? to open the file, read it and close it
> consumes a lot of CPU time. is there a better solution?

No. At least not if what you really want is always the full content of the
file. If you're only interested in the content if the file has actually
changed - thats a totally different animal, and is under unix doable using
stat-calls (somewhere in the os module). I'm not sure how much that extends
to windows, but I'm pretty much confident that there is similar stuff
available.

Diez-



More information about the Python-list mailing list