Пример #1
0
 def __init__(self, schedule=None, max_interval=None, app=None, Publisher=None, lazy=False, **kwargs):
     app = self.app = app_or_default(app)
     self.data = maybe_promise({} if schedule is None else schedule)
     self.max_interval = max_interval or app.conf.CELERYBEAT_MAX_LOOP_INTERVAL or self.max_interval
     self.Publisher = Publisher or app.amqp.TaskProducer
     if not lazy:
         self.setup_schedule()
Пример #2
0
 def _matcher(seq, *args, **kwargs):
     for cls in seq:
         try:
             answer = getattr(maybe_promise(cls), method)(*args, **kwargs)
             if answer is not None:
                 return answer
         except AttributeError:
             pass
 def _matcher(seq, *args, **kwargs):
     for cls in seq:
         try:
             answer = getattr(maybe_promise(cls), method)(*args, **kwargs)
             if answer is not None:
                 return answer
         except AttributeError:
             pass
Пример #4
0
 def _matcher(it, *args, **kwargs):
     for obj in it:
         try:
             answer = getattr(maybe_promise(obj), method)(*args, **kwargs)
         except AttributeError:
             pass
         else:
             if answer is not None:
                 return answer
Пример #5
0
 def _matcher(it, *args, **kwargs):
     for obj in it:
         try:
             answer = getattr(maybe_promise(obj), method)(*args, **kwargs)
         except AttributeError:
             pass
         else:
             if answer is not None:
                 return answer
Пример #6
0
    def test_prepare(self):
        o = object()
        R = [{'foo': 'bar'}, 'celery.utils.functional.LRUCache', o]
        p = routes.prepare(R)
        self.assertIsInstance(p[0], routes.MapRoute)
        self.assertIsInstance(maybe_promise(p[1]), LRUCache)
        self.assertIs(p[2], o)

        self.assertEqual(routes.prepare(o), [o])
Пример #7
0
    def test_prepare(self):
        from celery.datastructures import LRUCache
        o = object()
        R = [{'foo': 'bar'}, 'celery.datastructures.LRUCache', o]
        p = routes.prepare(R)
        self.assertIsInstance(p[0], routes.MapRoute)
        self.assertIsInstance(maybe_promise(p[1]), LRUCache)
        self.assertIs(p[2], o)

        self.assertEqual(routes.prepare(o), [o])
Пример #8
0
 def __init__(self, schedule=None, logger=None, max_interval=None,
         app=None, Publisher=None, lazy=False, **kwargs):
     app = self.app = app_or_default(app)
     self.data = maybe_promise({} if schedule is None else schedule)
     self.logger = logger or app.log.get_default_logger(name="celery.beat")
     self.max_interval = max_interval or \
                             app.conf.CELERYBEAT_MAX_LOOP_INTERVAL
     self.Publisher = Publisher or app.amqp.TaskPublisher
     if not lazy:
         self.setup_schedule()
Пример #9
0
 def __init__(self, schedule=None, max_interval=None,
         app=None, Publisher=None, lazy=False, **kwargs):
     app = self.app = app_or_default(app)
     self.data = maybe_promise({} if schedule is None else schedule)
     self.max_interval = (max_interval
                             or app.conf.CELERYBEAT_MAX_LOOP_INTERVAL
                             or self.max_interval)
     self.Publisher = Publisher or app.amqp.TaskProducer
     if not lazy:
         self.setup_schedule()
Пример #10
0
    def test_prepare(self):
        o = object()
        R = [{'foo': 'bar'},
             'celery.utils.functional.LRUCache', o]
        p = routes.prepare(R)
        self.assertIsInstance(p[0], routes.MapRoute)
        self.assertIsInstance(maybe_promise(p[1]), LRUCache)
        self.assertIs(p[2], o)

        self.assertEqual(routes.prepare(o), [o])
Пример #11
0
    def test_prepare(self):
        from celery.datastructures import LRUCache
        o = object()
        R = [{'foo': 'bar'},
             'celery.datastructures.LRUCache', o]
        p = routes.prepare(R)
        self.assertIsInstance(p[0], routes.MapRoute)
        self.assertIsInstance(maybe_promise(p[1]), LRUCache)
        self.assertIs(p[2], o)

        self.assertEqual(routes.prepare(o), [o])
Пример #12
0
 def test_evaluates(self):
     self.assertEqual(maybe_promise(promise(lambda: 10)), 10)
     self.assertEqual(maybe_promise(20), 20)
Пример #13
0
 def test_evaluates(self):
     self.assertEqual(maybe_promise(promise(lambda: 10)), 10)
     self.assertEqual(maybe_promise(20), 20)