seb-m / pyinotify

Monitoring filesystems events with inotify on Linux.
http://github.com/seb-m/pyinotify/wiki
MIT License
2.29k stars 379 forks source link

Daemonization #149

Open Bombastus42 opened 6 years ago

Bombastus42 commented 6 years ago

Hello. I made a script using pynotify, looking like this:

wm = pyinotify.WatchManager() # Watch Manager mask = pyinotify.IN_CREATE # watched events

class EventHandler(pyinotify.ProcessEvent): def process_IN_CREATE(self, event): f = open(event.pathname, 'r');

do stuff

    f.close()

handler = EventHandler() notifier = pyinotify.Notifier(wm, handler) wdd = wm.add_watch(watchedfolder, mask, rec=True) notifier.loop()

and I cannot figure out how to daemonize it because whenever I do that I end up losing the event class, which means I am unable to work with the file, since I just can't get to event.pathname. Is there any way how to do it?

Basically I would just need to know how to pass event class into callback function when using the daemonisation.