dsoprea / PyInotify

An efficient and elegant inotify (Linux filesystem activity monitor) library for Python. Python 2 and 3 compatible.
GNU General Public License v2.0
245 stars 73 forks source link

Using an Inotify object in select #37

Open KlaAr36 opened 6 years ago

KlaAr36 commented 6 years ago

I have reason to wait for either inotify events or stdin events and this code works:

    observer = inotify.adapters.Inotify()
    observer.add_watch(b'tmp')
    fd = observer._Inotify__inotify_fd
    [r, w, x] = select.select([sys.stdin, fd], [], [], 10)

But I would prefer this solution:

    observer = inotify.adapters.Inotify()
    observer.add_watch(b'tmp')
    [r, w, x] = select.select([sys.stdin, observer], [], [], 10)

I suspect it is a matter of implementing fileno() in Inotify:

   def fileno(self):
      return self.__inotify_fd