python program to watch a file - example.

Isaac To kkto at
Sun Sep 8 15:39:30 CEST 2002

>>>>> "Wayne" == Wayne R <wayne at> 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:


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.


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.


More information about the Python-list mailing list