In order to get notifications about file / directory / sys changes, I use polling objects from python.
import select
poll_objet = select.poll()
fd_object = file("/sys/what_you_want_to_survey", "r")
poll_objet.register(fd_object)
result = poll_object.poll()
where result is the list (fd, event) that has been affected.
source
share