Python 3 file change event listener in linux using no modules or installs

191 views Asked by At

I have a number of async threads in which I would like to trigger an event on file change.

Ideally it would work similarly to watchdog or inotify, but I am unable to install anything including new modules (Compliance and politics). There are about 100 files that may change. This will be deployed across a fleet of about 150,000 linux instances using Python 3.5 as a minimum. It really needs to be as efficient as possible, so I don't want threads to sit in while loops. It also needs to be fairly timely. I'm expecting multiple changes within a second at times, so delays and sleep timers is also out.

Is there any possible way to use the same mechanisms as watchdog/inotify, some default module, or some other method to achieve this?

1024 Thanks!

1

There are 1 answers

0
scaramanga On

You could take a look at minotaur. If you can't install it as a module, you can just include the code as it is permissively licensed. Or just copy the ideas. It's a very small cpython extension around inotify with a, pythonic wrapper in python.