我正在尝试从处理的方法返回一个值。我是使用 pyinotify 的新手,代码是:
import pyinotify
import time
wm = pyinotify.WatchManager()
mask = pyinotify.IN_OPEN
class EventHandler(pyinotify.ProcessEvent):
endGame = False
def process_IN_OPEN(self, event):
print "Opening:", event.pathname
endGame = True
handler = EventHandler()
notifier = pyinotify.Notifier(wm, handler)
wdd = wm.add_watch('./file.json', mask, rec=True)
wm.rm_watch(wdd.values())
while not handler.endGame:
time.sleep(1)
notifier.stop()
print "end game"
但是当我打开 file.json 时,endGame 变量永远不会变为 True。我究竟做错了什么?