python program to watch a file - example.

Isaac To kkto at csis.hku.hk
Sun Sep 8 09:39:30 EDT 2002


>>>>> "Wayne" == Wayne R <wayne at tbnets.com> writes:

    Wayne> I am trying to write a python program that will run as a deamon
    Wayne> and watch a file for data to arrive and then wake up and perform
    Wayne> duties on that data.  I found ways to make a python program run
    Wayne> as a deamon but I am at a loss to find anything related to
    Wayne> watching a file for data so that it can then process the data.  I
    Wayne> didn't really want to do a sleep loop or something like, I am
    Wayne> sure there is a better way.
 
    Wayne> Any ideas or links to more info?
 
See this:

                      http://oss.sgi.com/projects/fam/

Basically, the established interface to access such functionalities in OS,
if implemented, is the C++ library called FAM (File Alteration Monitor).
Perhaps you have to write a module to make it accessible from within Python.
Internally, IRIX use the /dev/imon device to provide such functionality.

             http://www.mcsr.olemiss.edu/cgi-bin/man-cgi?imon+7

Linux has the fcntl called "F_NOTIFY" (see Documentation/dnotify.txt in your
kernel source).  Other OS probably has no interface to get it done, so you
are back to a timed loop.

Regards,
Isaac.



More information about the Python-list mailing list