'Read event from `inotify` and add them to `queue`. When reading a
IN_MOVE_TO event, remove the previous added matching IN_MOVE_FROM event
and add them back to the queue as a tuple.'

def run(self):

    deleted_self = False
    while (self.should_keep_running() and (not deleted_self)):
        inotify_events = self._inotify.read_events()
        for inotify_event in inotify_events:
            logger.debug('in-event    %s', inotify_event)
            if inotify_event.is_moved_to:
                def matching_from_event(event):
                    return ((not isinstance(event, tuple)) and event.is_moved_from and (event.cookie == inotify_event.cookie))
                from_event = self._queue.remove(matching_from_event)
                if (from_event is not None):
                    self._queue.put((from_event, inotify_event))
                else:
                    logger.debug('could    not    find    matching    move_from    event')
                    self._queue.put(inotify_event)
            else:
                self._queue.put(inotify_event)
            if (inotify_event.is_delete_self and (inotify_event.src_path == self._inotify.path)):
                deleted_self = True
