Make pyinotify daemon die after a certain amount of time

305 Views Asked by At

I have a process which is writing .txt files to a directory. I use pyinotify to monitor the directory and count the number of files written the directory. There is a max number of txt files that will be written. After this limit is reached, the pyinotify process dies gracefully. Now in case the file writing process fails and dies, and the number of files never reaches the limit, I want the pyinotify process to die after running for 1200 seconds. For this, I am setting up the notifier using the following statmeent

notifier = pyinotify.Notifier(wm,handler,0,0,1200)

now the 1200 here is the is the value of the timeout. In the pyinotify code the init function for the Notifier is as follows def init(self, watch_manager, default_proc_fun=None, read_freq=0, threshold=0, timeout=None):

I would like 1200 to be the timeout value. Unfortunately the process continues to run past 1200 seconds. Is there something I am doing wrong.

Please help.

1

There are 1 best solutions below

0
On

So the 1200 there is the polling interval in msec : Polling Objects

It is not the amount of time the daemon will run for. I still need an elegant fix to this. I am thinking I will change the code of pyinotify to add this functionality.