def start_rtsync(self):
if self.notifier is None:
self.watchman = pyinotify.WatchManager()
self.notifier = pyinotify.ThreadedNotifier(self.watchman, self.syncevt, read_freq=self.watch_delay)
self.notifier.coalesce_events(True)
mask = self.get_mask()
wpaths = self.syncevt.get_wpaths()
for awpath in wpaths:
self.logger.debug("adding %s to sync watches" %awpath['src'])
wpath = copy.deepcopy(awpath)
self.watchman.add_watch(wpath['src'], mask, rec=True, auto_add=True)
# do an initial sync, dont wait for rsync to finish.
wpath['wait']=False
self.rsync.sync(**wpath)
self.logger.debug("starting notifier...")
self.notifier.start()
else:
self.logger.debug("start_rtsync called by notifier not none.")
评论列表
文章目录