Beispiel #1
0
    def Run(self):
        while 1:
            handles = [self.stopEvent, self.adminEvent]
            if self.watchEvent is not None:
                handles.append(self.watchEvent)
            rc = win32event.WaitForMultipleObjects(handles, 0, win32event.INFINITE)
            if rc == win32event.WAIT_OBJECT_0:
                break
            elif rc == win32event.WAIT_OBJECT_0 + 1:
                self.RefreshEvent()
            else:
                win32api.PostMessage(self.hwnd, MSG_CHECK_EXTERNAL_FILE, 0, 0)
                try:
                    # If the directory has been removed underneath us, we get this error.
                    win32api.FindNextChangeNotification(self.watchEvent)
                except win32api.error as exc:
                    print(
                        "Can not watch file",
                        self.doc.GetPathName(),
                        "for changes -",
                        exc.strerror,
                    )
                    break

        # close a circular reference
        self.doc = None
        if self.watchEvent:
            win32api.FindCloseChangeNotification(self.watchEvent)
Beispiel #2
0
 def poll_for_changes(self):
     for handle, path in self.handles.items():
         if win32api.WaitForSingleObject(handle):
             win32api.FindNextChangeNotification(handle)
             self.process_folder(path)
Beispiel #3
0
 def on_object_signaled(self, handle, abandoned):
     if abandoned:
         return
     win32api.FindNextChangeNotification(handle)
     self.process_folder(self.handles[handle])