예제 #1
0
    def test_maybe_evaluate(self):
        x = PromiseProxy(lambda: 30)
        self.assertFalse(x.__evaluated__())
        self.assertEqual(maybe_evaluate(x), 30)
        self.assertEqual(maybe_evaluate(x), 30)

        self.assertEqual(maybe_evaluate(30), 30)
        self.assertTrue(x.__evaluated__())
예제 #2
0
    def test_maybe_evaluate(self):
        x = PromiseProxy(lambda: 30)
        self.assertFalse(x.__evaluated__())
        self.assertEqual(maybe_evaluate(x), 30)
        self.assertEqual(maybe_evaluate(x), 30)

        self.assertEqual(maybe_evaluate(30), 30)
        self.assertTrue(x.__evaluated__())
예제 #3
0
파일: test_local.py 프로젝트: bryson/celery
    def test_maybe_evaluate(self):
        x = PromiseProxy(lambda: 30)
        assert not x.__evaluated__()
        assert maybe_evaluate(x) == 30
        assert maybe_evaluate(x) == 30

        assert maybe_evaluate(30) == 30
        assert x.__evaluated__()
예제 #4
0
파일: base.py 프로젝트: sarang4/celery
    def finalize(self):
        if not self.finalized:
            load_shared_tasks(self)

            pending = self._pending
            while pending:
                maybe_evaluate(pending.pop())
            self.finalized = True
예제 #5
0
    def finalize(self):
        if not self.finalized:
            load_builtin_tasks(self)

            pending = self._pending
            while pending:
                maybe_evaluate(pending.pop())
            self.finalized = True
예제 #6
0
    def test_maybe_evaluate(self):
        x = PromiseProxy(lambda: 30)
        assert not x.__evaluated__()
        assert maybe_evaluate(x) == 30
        assert maybe_evaluate(x) == 30

        assert maybe_evaluate(30) == 30
        assert x.__evaluated__()
예제 #7
0
파일: base.py 프로젝트: bmihelac/celery
    def finalize(self):
        """Finalizes the app by loading built-in tasks,
        and evaluating pending task decorators."""
        if not self.finalized:
            load_builtin_tasks(self)

            pending = self._pending
            while pending:
                maybe_evaluate(pending.pop())
            self.finalized = True
예제 #8
0
파일: base.py 프로젝트: markferrer/celery
    def finalize(self):
        if not self.finalized:
            self.finalized = True
            load_shared_tasks(self)

            pending = self._pending
            while pending:
                maybe_evaluate(pending.pop())

            for task in self._tasks.itervalues():
                task.bind(self)
예제 #9
0
    def finalize(self):
        if not self.finalized:
            self.finalized = True
            load_shared_tasks(self)

            pending = self._pending
            while pending:
                maybe_evaluate(pending.pop())

            for task in self._tasks.itervalues():
                task.bind(self)
예제 #10
0
    def finalize(self):
        with self._finalize_mutex:
            if not self.finalized:
                self.finalized = True
                load_shared_tasks(self)

                pending = self._pending
                while pending:
                    maybe_evaluate(pending.popleft())

                for task in values(self._tasks):
                    task.bind(self)
예제 #11
0
    def finalize(self):
        with self._finalize_mutex:
            if not self.finalized:
                self.finalized = True
                load_shared_tasks(self)

                pending = self._pending
                while pending:
                    maybe_evaluate(pending.popleft())

                for task in values(self._tasks):
                    task.bind(self)
예제 #12
0
    def finalize(self, auto=False):
        with self._finalize_mutex:
            if not self.finalized:
                if auto and not self.autofinalize:
                    raise RuntimeError("Contract breach: app not finalized")
                self.finalized = True
                _announce_app_finalized(self)

                pending = self._pending
                while pending:
                    maybe_evaluate(pending.popleft())

                for task in values(self._tasks):
                    task.bind(self)
예제 #13
0
    def finalize(self, auto=False):
        with self._finalize_mutex:
            if not self.finalized:
                if auto and not self.autofinalize:
                    raise RuntimeError('Contract breach: app not finalized')
                self.finalized = True
                load_shared_tasks(self)

                pending = self._pending
                while pending:
                    maybe_evaluate(pending.popleft())

                for task in values(self._tasks):
                    task.bind(self)
예제 #14
0
파일: base.py 프로젝트: 277800076/celery
    def _load_config(self):
        if isinstance(self.on_configure, Signal):
            self.on_configure.send(sender=self)
        else:
            # used to be a method pre 4.0
            self.on_configure()
        if self._config_source:
            self.loader.config_from_object(self._config_source)

        self.configured = True
        settings = detect_settings(
            self.prepare_config(self.loader.conf), self._preconf,
            ignore_keys=self._preconf_set_by_auto, prefix=self.namespace,
        )
        if self._conf is not None:
            # replace in place, as someone may have referenced app.conf,
            # done some changes, accessed a key, and then try to make more
            # changes to the reference and not the finalized value.
            self._conf.swap_with(settings)
        else:
            self._conf = settings

        # load lazy config dict initializers.
        pending_def = self._pending_defaults
        while pending_def:
            self._conf.add_defaults(maybe_evaluate(pending_def.popleft()()))

        # load lazy periodic tasks
        pending_beat = self._pending_periodic_tasks
        while pending_beat:
            self._add_periodic_task(*pending_beat.popleft())

        self.on_after_configure.send(sender=self, source=self._conf)
        return self._conf
예제 #15
0
    def _load_config(self):
        if isinstance(self.on_configure, Signal):
            self.on_configure.send(sender=self)
        else:
            # used to be a method pre 4.0
            self.on_configure()
        if self._config_source:
            self.loader.config_from_object(self._config_source)
        self.configured = True
        settings = detect_settings(
            self.prepare_config(self.loader.conf),
            self._preconf,
            ignore_keys=self._preconf_set_by_auto,
            prefix=self.namespace,
        )
        if self._conf is not None:
            # replace in place, as someone may have referenced app.conf,
            # done some changes, accessed a key, and then try to make more
            # changes to the reference and not the finalized value.
            self._conf.swap_with(settings)
        else:
            self._conf = settings

        # load lazy config dict initializers.
        pending_def = self._pending_defaults
        while pending_def:
            self._conf.add_defaults(maybe_evaluate(pending_def.popleft()()))

        # load lazy periodic tasks
        pending_beat = self._pending_periodic_tasks
        while pending_beat:
            self._add_periodic_task(*pending_beat.popleft())

        self.on_after_configure.send(sender=self, source=self._conf)
        return self._conf
예제 #16
0
파일: base.py 프로젝트: RaymondKlass/celery
    def _load_config(self):
        if isinstance(self.on_configure, Signal):
            self.on_configure.send(sender=self)
        else:
            # used to be a method pre 4.0
            self.on_configure()
        if self._config_source:
            self.loader.config_from_object(self._config_source)
        defaults = dict(deepcopy(DEFAULTS), **self._preconf)
        self.configured = True
        s = self._conf = Settings(
            {}, [self.prepare_config(self.loader.conf), defaults],
        )
        # load lazy config dict initializers.
        pending_def = self._pending_defaults
        while pending_def:
            s.add_defaults(maybe_evaluate(pending_def.popleft()()))

        # load lazy periodic tasks
        pending_beat = self._pending_periodic_tasks
        while pending_beat:
            self._add_periodic_task(*pending_beat.popleft())

        # Settings.__setitem__ method, set Settings.change
        if self._preconf:
            for key, value in items(self._preconf):
                setattr(s, key, value)
        self.on_after_configure.send(sender=self, source=s)
        return s
예제 #17
0
    def _load_config(self):
        if isinstance(self.on_configure, Signal):
            self.on_configure.send(sender=self)
        else:
            # used to be a method pre 4.0
            self.on_configure()
        if self._config_source:
            self.loader.config_from_object(self._config_source)
        defaults = dict(deepcopy(DEFAULTS), **self._preconf)
        self.configured = True
        s = self._conf = Settings(
            {}, [self.prepare_config(self.loader.conf), defaults],
        )
        # load lazy config dict initializers.
        pending_def = self._pending_defaults
        while pending_def:
            s.add_defaults(maybe_evaluate(pending_def.popleft()()))

        # load lazy periodic tasks
        pending_beat = self._pending_periodic_tasks
        while pending_beat:
            self._add_periodic_task(*pending_beat.popleft())

        # Settings.__setitem__ method, set Settings.change
        if self._preconf:
            for key, value in items(self._preconf):
                setattr(s, key, value)
        self.on_after_configure.send(sender=self, source=s)
        return s
예제 #18
0
    def _load_config(self):
        if isinstance(self.on_configure, Signal):
            self.on_configure.send(sender=self)
        else:
            # used to be a method pre 3.2
            self.on_configure()
        if self._config_source:
            self.loader.config_from_object(self._config_source)
        defaults = dict(deepcopy(DEFAULTS), **self._preconf)
        self.configured = True
        s = self._conf = Settings(
            {},
            [self.prepare_config(self.loader.conf), defaults],
        )
        # load lazy config dict initializers.
        pending_def = self._pending_defaults
        while pending_def:
            s.add_defaults(maybe_evaluate(pending_def.popleft()()))

        # load lazy periodic tasks
        pending_beat = self._pending_periodic_tasks
        while pending_beat:
            pargs, pkwargs = pending_beat.popleft()
            self._add_periodic_task(*pargs, **pkwargs)
        self.on_after_configure.send(sender=self, source=s)
        return s
예제 #19
0
파일: base.py 프로젝트: shejianmin/celery
    def finalize(self, auto=False):
        """Finalizes the app by loading built-in tasks,
        and evaluating pending task decorators."""
        with self._finalize_mutex:
            if not self.finalized:
                if auto and not self.autofinalize:
                    raise RuntimeError('Contract breach: app not finalized')
                self.finalized = True
                _announce_app_finalized(self)

                pending = self._pending
                while pending:
                    maybe_evaluate(pending.popleft())

                for task in values(self._tasks):
                    task.bind(self)

                self.on_after_finalize.send(sender=self)
예제 #20
0
    def finalize(self, auto=False):
        """Finalize the app.

        This loads built-in tasks, evaluates pending task decorators,
        reads configuration, etc.
        """
        with self._finalize_mutex:
            if not self.finalized:
                if auto and not self.autofinalize:
                    raise RuntimeError('Contract breach: app not finalized')
                self.finalized = True
                _announce_app_finalized(self)

                pending = self._pending
                while pending:
                    maybe_evaluate(pending.popleft())

                for task in self._tasks.values():
                    task.bind(self)

                self.on_after_finalize.send(sender=self)
예제 #21
0
파일: base.py 프로젝트: sysras0000/panop
 def _get_config(self):
     self.on_configure()
     if self._config_source:
         self.loader.config_from_object(self._config_source)
     defaults = dict(deepcopy(DEFAULTS), **self._preconf)
     self.configured = True
     s = Settings({}, [self.prepare_config(self.loader.conf), defaults])
     # load lazy config dict initializers.
     pending = self._pending_defaults
     while pending:
         s.add_defaults(maybe_evaluate(pending.popleft()()))
     return s
예제 #22
0
    def _get_config(self):
        self.on_configure()
        self.configured = True
        s = Settings({}, [self.prepare_config(self.loader.conf),
                          deepcopy(DEFAULTS)])

        # load lazy config dict initializers.
        pending = self._pending_defaults
        while pending:
            s.add_defaults(maybe_evaluate(pending.popleft()()))
        if self._preconf:
            for key, value in items(self._preconf):
                setattr(s, key, value)
        return s
예제 #23
0
파일: base.py 프로젝트: xn8x/celery
 def _get_config(self):
     if isinstance(self.on_configure, Signal):
         self.on_configure.send(sender=self)
     else:
         # used to be a method pre 3.2
         self.on_configure()
     if self._config_source:
         self.loader.config_from_object(self._config_source)
     defaults = dict(deepcopy(DEFAULTS), **self._preconf)
     self.configured = True
     s = Settings({}, [self.prepare_config(self.loader.conf), defaults])
     # load lazy config dict initializers.
     pending = self._pending_defaults
     while pending:
         s.add_defaults(maybe_evaluate(pending.popleft()()))
     self.on_after_configure.send(sender=self, source=s)
     return s
예제 #24
0
    def _get_config(self):
        self.on_configure()
        if self._config_source:
            self.loader.config_from_object(self._config_source)
        self.configured = True
        s = Settings(
            {}, [self.prepare_config(self.loader.conf),
                 deepcopy(DEFAULTS)])
        # load lazy config dict initializers.
        pending = self._pending_defaults
        while pending:
            s.add_defaults(maybe_evaluate(pending.popleft()()))

        # preconf options must be explicitly set in the conf, and not
        # as defaults or they will not be pickled with the app instance.
        # This will cause errors when `CELERYD_FORCE_EXECV=True` as
        # the workers will not have a BROKER_URL, CELERY_RESULT_BACKEND,
        # or CELERY_IMPORTS set in the config.
        if self._preconf:
            s.update(self._preconf)
        return s
예제 #25
0
    def test_maybe_evaluate(self):
        x = PromiseProxy(lambda: 30)
        self.assertEqual(maybe_evaluate(x), 30)
        self.assertEqual(maybe_evaluate(x), 30)

        self.assertEqual(maybe_evaluate(30), 30)