Esempio n. 1
0
 def handle_read(self):
     buf = self.recv(self.bufsize)
     if buf:
         for event in inotify.unpack_events(buf):
             self.handle_watch(event)
     else:
         self.close()
Esempio n. 2
0
    def _iter(self):
        while True:
            try:
                readable, _, _ = select.select([self._fd, self._pipe[0]], [], [])
            except select.error as e:
                if e.args[0] == errno.EINTR:
                    continue
                raise

            if self._fd in readable:
                try:
                    buf = os.read(self._fd, self._bufsize)
                except OSError as e:
                    if e.errno != errno.EAGAIN:
                        raise
                else:
                    assert buf
                    for event in inotify.unpack_events(buf):
                        yield event

            if self._pipe[0] in readable:
                try:
                    os.read(self._pipe[0], 1)
                except OSError as e:
                    if e.errno != errno.EAGAIN:
                        raise
                else:
                    break