class_docstr: kqueue(2)-based event emitter.
  
  .. ADMONITION:: About ``kqueue(2)`` behavior and this implementation
  
            ``kqueue(2)`` monitors file system events only for
            open descriptors, which means, this emitter does a lot of
            book-keeping behind the scenes to keep track of open
            descriptors for every entry in the monitored directory tree.
  
            This also means the number of maximum open file descriptors
            on your system must be increased **manually**.
            Usually, issuing a call to ``ulimit`` should suffice::
  
                ulimit -n 1024
  
            Ensure that you pick a number that is larger than the
            number of files you expect to be monitored.
  
            ``kqueue(2)`` does not provide enough information about the
            following things:
  
            * The destination path of a file or directory that is renamed.
            * Creation of a file or directory within a directory; in this
              case, ``kqueue(2)`` only indicates a modified event on the
              parent directory.
  
            Therefore, this emitter takes a snapshot of the directory
            tree when ``kqueue(2)`` detects a change on the file system
            to be able to determine the above information.
  
  :param event_queue:
      The event queue to fill with events.
  :param watch:
      A watch object representing the directory to monitor.
  :type watch:
      :class:`watchdog.observers.api.ObservedWatch`
  :param timeout:
      Read events blocking timeout (in seconds).
  :type timeout:
      ``float``
class_docstr_tok: ["kqueue","(","2",")","-based","event","emitter",".","..","ADMONITION",":",":","About","``","kqueue","(","2",")","``","behavior","and","this","implementation","``","kqueue","(","2",")","``","monitors","file","system","events","only","for","open","descriptors",",","which","means",",","this","emitter","does","a","lot","of","book-keeping","behind","the","scenes","to","keep","track","of","open","descriptors","for","every","entry","in","the","monitored","directory","tree",".","This","also","means","the","number","of","maximum","open","file","descriptors","on","your","system","must","be","increased","*","*","manually","*","*",".","Usually",",","issuing","a","call","to","``","ulimit","``","should","suffice",":",":","ulimit","-n","1024","Ensure","that","you","pick","a","number","that","is","larger","than","the","number","of","files","you","expect","to","be","monitored",".","``","kqueue","(","2",")","``","does","not","provide","enough","information","about","the","following","things",":","*","The","destination","path","of","a","file","or","directory","that","is","renamed",".","*","Creation","of","a","file","or","directory","within","a","directory",";","in","this","case",",","``","kqueue","(","2",")","``","only","indicates","a","modified","event","on","the","parent","directory",".","Therefore",",","this","emitter","takes","a","snapshot","of","the","directory","tree","when","``","kqueue","(","2",")","``","detects","a","change","on","the","file","system","to","be","able","to","determine","the","above","information",".",":","param","event_queue",":","The","event","queue","to","fill","with","events",".",":","param","watch",":","A","watch","object","representing","the","directory","to","monitor",".",":","type","watch",":",":","class",":","`","watchdog.observers.api.ObservedWatch","`",":","param","timeout",":","Read","events","blocking","timeout","(","in","seconds",")",".",":","type","timeout",":","``","float","``"]
docstr: Compares information from two directory snapshots (one taken before
  the rename operation and another taken right after) to determine the
  destination path of the file system object renamed, and adds
  appropriate events to the event queue.
docstr_tok: ["Compares","information","from","two","directory","snapshots","(","one","taken","before","the","rename","operation","and","another","taken","right","after",")","to","determine","the","destination","path","of","the","file","system","object","renamed",",","and","adds","appropriate","events","to","the","event","queue","."]
code: def _queue_renamed(
      self, src_path, is_directory, ref_snapshot, new_snapshot
  ):
      """
      Compares information from two directory snapshots (one taken before
      the rename operation and another taken right after) to determine the
      destination path of the file system object renamed, and adds
      appropriate events to the event queue.
      """
      try:
          ref_stat_info = ref_snapshot.stat_info(src_path)
      except KeyError:
          # Probably caught a temporary file/directory that was renamed
          # and deleted. Fires a sequence of created and deleted events
          # for the path.
          if is_directory:
              self.queue_event(DirCreatedEvent(src_path))
              self.queue_event(DirDeletedEvent(src_path))
          else:
              self.queue_event(FileCreatedEvent(src_path))
              self.queue_event(FileDeletedEvent(src_path))
              # We don't process any further and bail out assuming
          # the event represents deletion/creation instead of movement.
          return
  
      try:
          dest_path = absolute_path(
              new_snapshot.path_for_inode(ref_stat_info.st_ino)
          )
          if is_directory:
              event = DirMovedEvent(src_path, dest_path)
              # TODO: Do we need to fire moved events for the items
              # inside the directory tree? Does kqueue does this
              # all by itself? Check this and then enable this code
              # only if it doesn't already.
              # A: It doesn't. So I've enabled this block.
              if self.watch.is_recursive:
                  for sub_event in event.sub_moved_events():
                      self.queue_event(sub_event)
              self.queue_event(event)
          else:
              self.queue_event(FileMovedEvent(src_path, dest_path))
      except KeyError:
          # If the new snapshot does not have an inode for the
          # old path, we haven't found the new name. Therefore,
          # we mark it as deleted and remove unregister the path.
          if is_directory:
              self.queue_event(DirDeletedEvent(src_path))
          else:
              self.queue_event(FileDeletedEvent(src_path))
  
imports: from __future__ import with_statement
  from wandb_watchdog.utils import platform
  import threading
  import errno
  import sys
  import stat
  import os
  from wandb_watchdog.observers.api import BaseObserver, EventEmitter, DEFAULT_OBSERVER_TIMEOUT, DEFAULT_EMITTER_TIMEOUT
  from wandb_watchdog.utils.dirsnapshot import DirectorySnapshot
  from wandb_watchdog.events import DirMovedEvent, DirDeletedEvent, DirCreatedEvent, DirModifiedEvent, FileMovedEvent, FileDeletedEvent, FileCreatedEvent, FileModifiedEvent, EVENT_TYPE_MOVED, EVENT_TYPE_DELETED, EVENT_TYPE_CREATED
label_desc: Use image node_id 7 for calling the KqueueEmitter obj's underlying member method code with example usage: obj._queue_renamed(src_path, is_directory, ref_snapshot, new_snapshot) without return types