diff options
Diffstat (limited to 'bitbake/lib/pyinotify.py')
-rw-r--r-- | bitbake/lib/pyinotify.py | 48 |
1 files changed, 14 insertions, 34 deletions
diff --git a/bitbake/lib/pyinotify.py b/bitbake/lib/pyinotify.py index 1528a22e8d..3c5dab0312 100644 --- a/bitbake/lib/pyinotify.py +++ b/bitbake/lib/pyinotify.py @@ -52,7 +52,6 @@ from collections import deque from datetime import datetime, timedelta import time import re -import asyncore import glob import locale import subprocess @@ -596,14 +595,24 @@ class _ProcessEvent: @type event: Event object @return: By convention when used from the ProcessEvent class: - Returning False or None (default value) means keep on - executing next chained functors (see chain.py example). + executing next chained functors (see chain.py example). - Returning True instead means do not execute next processing functions. @rtype: bool @raise ProcessEventError: Event object undispatchable, unknown event. """ - stripped_mask = event.mask - (event.mask & IN_ISDIR) + stripped_mask = event.mask & ~IN_ISDIR + # Bitbake hack - we see event masks of 0x6, i.e., IN_MODIFY & IN_ATTRIB. + # The kernel inotify code can set more than one of the bits in the mask, + # fsnotify_change() in linux/fsnotify.h is quite clear that IN_ATTRIB, + # IN_MODIFY and IN_ACCESS can arrive together. + # This breaks the code below which assume only one mask bit is ever + # set in an event. We don't care about attrib or access in bitbake so + # drop those. + if stripped_mask & IN_MODIFY: + stripped_mask &= ~(IN_ATTRIB | IN_ACCESS) + maskname = EventsCodes.ALL_VALUES.get(stripped_mask) if maskname is None: raise ProcessEventError("Unknown mask 0x%08x" % stripped_mask) @@ -1274,7 +1283,7 @@ class Notifier: basename = os.path.basename(sys.argv[0]) or 'pyinotify' pid_file = os.path.join(dirname, basename + '.pid') - if pid_file != False and os.path.lexists(pid_file): + if pid_file and os.path.lexists(pid_file): err = 'Cannot daemonize: pid file %s already exists.' % pid_file raise NotifierError(err) @@ -1308,7 +1317,7 @@ class Notifier: fork_daemon() # Write pid - if pid_file != False: + if pid_file: flags = os.O_WRONLY|os.O_CREAT|os.O_NOFOLLOW|os.O_EXCL fd_pid = os.open(pid_file, flags, 0o0600) os.write(fd_pid, bytes(str(os.getpid()) + '\n', @@ -1475,35 +1484,6 @@ class ThreadedNotifier(threading.Thread, Notifier): self.loop() -class AsyncNotifier(asyncore.file_dispatcher, Notifier): - """ - This notifier inherits from asyncore.file_dispatcher in order to be able to - use pyinotify along with the asyncore framework. - - """ - def __init__(self, watch_manager, default_proc_fun=None, read_freq=0, - threshold=0, timeout=None, channel_map=None): - """ - Initializes the async notifier. The only additional parameter is - 'channel_map' which is the optional asyncore private map. See - Notifier class for the meaning of the others parameters. - - """ - Notifier.__init__(self, watch_manager, default_proc_fun, read_freq, - threshold, timeout) - asyncore.file_dispatcher.__init__(self, self._fd, channel_map) - - def handle_read(self): - """ - When asyncore tells us we can read from the fd, we proceed processing - events. This method can be overridden for handling a notification - differently. - - """ - self.read_events() - self.process_events() - - class TornadoAsyncNotifier(Notifier): """ Tornado ioloop adapter. |