diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2015-08-17 12:12:18 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-08-17 14:40:56 +0100 |
commit | bc39b8da34c046b629c43fd0a8cac2efbf1c060f (patch) | |
tree | e514cfc9a33c1c75ff1f1580eddf6e48ab95d745 /lib/bb/cooker.py | |
parent | 95e391acbc3b4efd6c77637a1ce815012ae0f09b (diff) | |
download | bitbake-contrib-bc39b8da34c046b629c43fd0a8cac2efbf1c060f.tar.gz |
cooker: further limit inotify watches
Unfortunately we were acting on inotify notifications about any files
changing within the watched directories, not just the ones we actually
care about. In OE the build directory is in BBPATH and hence it gets
watched, and we write things like bitbake.lock and
bitbake-cookerdaemon.log to that directory, hence effectively
notifications were being tripped on every bitbake invocation. To avoid
this, record which file/subdirectory we're interested in against each
watched directory so we can ignore any events for files/subdirectories
we don't care about.
Additionally, if we move up to the parent dir, ensure we haven't already
seen it before adding a watch on it (we were previously calling
watcher.add_watch() on the same directory multiple times before in a
typical OE configuration).
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/cooker.py')
-rw-r--r-- | lib/bb/cooker.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py index 84bf46b9e..f0f9c66f4 100644 --- a/lib/bb/cooker.py +++ b/lib/bb/cooker.py @@ -126,12 +126,14 @@ class BBCooker: self.configwatcher = pyinotify.WatchManager() self.configwatcher.bbseen = [] + self.configwatcher.bbwatchedfiles = [] self.confignotifier = pyinotify.Notifier(self.configwatcher, self.config_notifications) self.watchmask = pyinotify.IN_CLOSE_WRITE | pyinotify.IN_CREATE | pyinotify.IN_DELETE | \ pyinotify.IN_DELETE_SELF | pyinotify.IN_MODIFY | pyinotify.IN_MOVE_SELF | \ pyinotify.IN_MOVED_FROM | pyinotify.IN_MOVED_TO self.watcher = pyinotify.WatchManager() self.watcher.bbseen = [] + self.watcher.bbwatchedfiles = [] self.notifier = pyinotify.Notifier(self.watcher, self.notifications) @@ -185,6 +187,8 @@ class BBCooker: signal.signal(signal.SIGHUP, self.sigterm_exception) def config_notifications(self, event): + if not event.pathname in self.configwatcher.bbwatchedfiles: + return if not event.path in self.inotify_modified_files: self.inotify_modified_files.append(event.path) self.baseconfig_valid = False @@ -198,20 +202,27 @@ class BBCooker: if not watcher: watcher = self.watcher for i in deps: + watcher.bbwatchedfiles.append(i[0]) f = os.path.dirname(i[0]) if f in watcher.bbseen: continue watcher.bbseen.append(f) + watchtarget = None while True: # We try and add watches for files that don't exist but if they did, would influence # the parser. The parent directory of these files may not exist, in which case we need # to watch any parent that does exist for changes. try: watcher.add_watch(f, self.watchmask, quiet=False) + if watchtarget: + watcher.bbwatchedfiles.append(watchtarget) break except pyinotify.WatchManagerError as e: if 'ENOENT' in str(e): + watchtarget = f f = os.path.dirname(f) + if f in watcher.bbseen: + break watcher.bbseen.append(f) continue if 'ENOSPC' in str(e): |