Example #1
0
    def __call__(self, operation, *args):
        """
        Magic method which calls a specific method from a view.

        In Fuse API, almost each method receives a path argument. Based on that
        path we can route each call to a specific view. For example, if a
        method which has a path argument like `/current/dir1/dir2/file1` is
        called, we need to get the certain view that will know how to handle
        this path, instantiate it and then call our method on the newly created
        object.

        :param str operation: Method name to be called
        :param args: tuple containing the arguments to be transmitted to
            the method
        :rtype: function
        """

        if operation in ['destroy', 'init']:
            view = self
        else:
            path = args[0]
            view, relative_path = self.get_view(path)
            args = (relative_path, ) + args[1:]

        log.debug('Call %s %s with %r' %
                  (operation, view.__class__.__name__, args))

        if not hasattr(view, operation):
            log.debug('No attribute %s on %s' %
                      (operation, view.__class__.__name__))
            raise FuseOSError(ENOSYS)

        idle.clear()
        return getattr(view, operation)(*args)
Example #2
0
    def __call__(self, operation, *args):
        """
        Magic method which calls a specific method from a view.

        In Fuse API, almost each method receives a path argument. Based on that
        path we can route each call to a specific view. For example, if a
        method which has a path argument like `/current/dir1/dir2/file1` is
        called, we need to get the certain view that will know how to handle
        this path, instantiate it and then call our method on the newly created
        object.

        :param str operation: Method name to be called
        :param args: tuple containing the arguments to be transmitted to
            the method
        :rtype: function
        """

        if operation in ['destroy', 'init']:
            view = self
        else:
            path = args[0]
            view, relative_path = self.get_view(path)
            args = (relative_path,) + args[1:]

        log.debug('Call %s %s with %r' % (operation,
                                          view.__class__.__name__,
                                          args))

        if not hasattr(view, operation):
            log.debug('No attribute %s on %s' % (operation,
                      view.__class__.__name__))
            raise FuseOSError(ENOSYS)

        idle.clear()
        return getattr(view, operation)(*args)
Example #3
0
    def work(self):
        idle_times = 0
        while True:
            if shutting_down.is_set():
                log.info("Stop sync worker")
                break

            try:
                job = self.commit_queue.get(timeout=self.timeout, block=True)
                if job['type'] == 'commit':
                    self.commits.append(job)
                log.debug("Got a commit job")

                idle_times = 0
                idle.clear()
            except Empty:
                log.debug("Nothing to do right now, going idle")

                if idle_times > self.min_idle_times:
                    idle.set()

                idle_times += 1
                self.on_idle()
Example #4
0
    def work(self):
        idle_times = 0
        while True:
            if shutting_down.is_set():
                log.info("Stop sync worker")
                break

            try:
                job = self.commit_queue.get(timeout=self.timeout, block=True)
                if job["type"] == "commit":
                    self.commits.append(job)
                log.debug("Got a commit job")

                idle_times = 0
                idle.clear()
            except Empty:
                log.debug("Nothing to do right now, going idle")

                if idle_times > self.min_idle_times:
                    idle.set()

                idle_times += 1
                self.on_idle()