我只是想知道如何获取pyinotify.ThreadedNotifier
调用我的 EventHandler 的名称。
pyinotify.ThreadedNotifier
自动获取名称,如“Thread-1”、“Thread-2”等。
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)
我可以使用该getName()
函数获取通知程序的名称,但我不知道如何找出其中哪些调用了 my EventHandler()
.
有没有办法找出来?