[Tutor] monitor number of files in a folder

Dave Angel davea at ieee.org
Fri Aug 7 00:08:55 CEST 2009


Sander Sweers wrote:
> 2009/8/6 Dave Angel <davea at ieee.org>:
>   
>> You have to choose your poison.
>>     
>
> I prefer no poison. This is exactly what inotiy was made for and
> although I never used it there is a python module for it [1]. It would
> be great if you can post your experience with it.
>
> Greets
> Sander
>
> [1] http://trac.dbzteam.org/pyinotify/wiki
>
>   
pyinotify solves an interesting problem, and if it worked on Windows, I 
already have a client with an application for it.  But it has little to 
do with the OP's question.

The problem the OP had was how to break out of a while loop, if the 
single condition never got satisfied.  The simplest answer is to make a 
second condition (timeout), and use and.  But that creates a second 
problem -- what to do if it did timeout.  That's the poison he had to 
choose between.

The time when pyinotify becomes very useful is if there are a large 
number of files/directories involved, and polling would be too slow.  
Presumably, the supported OS provides some event notification when a 
file is changed, and this module builds on that.

DaveA



More information about the Tutor mailing list