code: def get_events(fd, timeout=None):
      
      (rlist, _, _) = select([fd], [], [], timeout)
      if not rlist:
          return []
      events = []
  
      while True:
          buf = os.read(fd, _BUF_LEN)
          i = 0
          while i < len(buf):
              (wd, mask, cookie, len_) = struct.unpack_from(_EVENT_FMT, buf, i)
              name = None
              if len_ > 0:
                  start = i + _EVENT_SIZE
                  end = start + len_
                  # remove \0 terminator and padding
                  name = buf[start:end].rstrip(b'\0').decode(ENCODING)
  
              events.append(InotifyEvent(wd, mask, cookie, name))
              i += _EVENT_SIZE + len_
  
          (rlist, _, _) = select([fd], [], [], 0)
          if not rlist:
              break
  
      return events
docs: get_events(fd[, timeout])
  
      Return a list of InotifyEvent instances representing events read from
      inotify.  If timeout is None, this will block forever until at least one
      event can be read.  Otherwise, timeout should be an integer or float
      specifying a timeout in seconds.  If get_events times out waiting for
      events, an empty list will be returned.  If timeout is zero, get_events
      will not block.
      This version of get_events() will only block the current greenlet.