[Twisted-Python] "Directory triggers" with kqueue using Twisted? (on MacOS X / FreeBSD)

Bob Ippolito bob at redivi.com
Thu Jan 13 13:51:30 MST 2005


On Jan 13, 2005, at 15:40, Wolfgang Keller wrote:

> recently I read something about the "kqueue" event notification 
> mechanism
> built into FreeBSD and that it would allow to receive notification when
> filesystem contents change. Would this mechanism allow to implement a
> similar function as database triggers for a filesystem, i.e. write a 
> script
> that does something with files that are added to, modified in or 
> deleted
> from a certain directory without having to poll the filesystem all the
> time? Folder actions allow such things on MacOS X, but Applescript is 
> slow
> and I would prefer Python anyway. ;-) If so, is there a way to write 
> such
> scripts in Python using Twisted?

Actually Folder Actions don't allow this.  I am relatively certain that 
they are implemented entirely in Finder.  They *might* be hooked into 
at the CoreServices/Carbon APIs, but DEFINITELY NOT the BSD level APIs 
(in Mac OS X 10.3 and earlier anyway).

The kernel in Mac OS X 10.3.0 supports kqueue, so you can use it for 
this sort of thing -- but Finder still polls.  I do not know what is 
necessary to integrate this with Twisted, though.  There is some 
support for kqueue in Twisted, but last I remember you need to download 
and patch some years-old extension and compile it in order to get that 
to work.

Another thing of interest to you might be FAM 
<http://oss.sgi.com/projects/fam/>.

-bob





More information about the Twisted-Python mailing list