I was just wondering how to get the name of a pyinotify.ThreadedNotifier
calling my EventHandler.
pyinotify.ThreadedNotifier
automatically get's a name like "Thread-1", "Thread-2", and so on.
import pyinotify
class EventHandler(pyinotify.ProcessEvent):
def process_default(self, event):
print "TRIGGER:", event.pathname
# Thread #1
wm1 = pyinotify.WatchManager()
notifier1 = pyinotify.ThreadedNotifier(wm1, EventHandler())
notifier1.start()
print notifier1.getName()
wm1.add_watch('/tmp/a', pyinotify.ALL_EVENTS, rec=True, auto_add=True)
# Thread #2
wm2 = pyinotify.WatchManager()
notifier2 = pyinotify.ThreadedNotifier(wm2, EventHandler())
notifier2.start()
print notifier2.getName()
wm2.add_watch('/tmp/b', pyinotify.ALL_EVENTS, rec=False, auto_add=False)
I can get the name of the notifier with the getName()
function, but I have no idea how to find out which of them has called my EventHandler()
.
Is there a way to find out ?