def __init__(self): if hasattr(self, '_fd'): # Constructor already called. (We may be called again implicitly # due to singleton behaviour in __new__ return if not _inotify: self._fd = -1 raise SystemError, "INotify support not compiled." self.signals = { # Master signal: this signal gets emitted on all events. "event": kaa.Signal() } self._watches = {} self._watches_by_path = {} # We keep track of recently removed watches so we don't get confused # if an event callback removes a watch while we're currently # processing a batch of events and we receive an event for a watch # we just removed. self._watches_recently_removed = [] self._read_buffer = "" self._move_state = None # For MOVED_FROM events self._moved_timer = kaa.WeakOneShotTimer(self._emit_last_move) self._fd = _inotify.init() if self._fd < 0: raise SystemError, "INotify support not detected on this system." fcntl.fcntl(self._fd, fcntl.F_SETFL, os.O_NONBLOCK) self._mon = kaa.WeakIOMonitor(self._handle_data) self._mon.register(self._fd)
def __init__(self): '''Create a new inotify instance.''' self.fd = inotify.init() self._paths = {} self._wds = {}