Exemple #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()
Exemple #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
Exemple #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
Exemple #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
Exemple #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])
    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])
Exemple #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()
Exemple #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()
Exemple #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])
    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])
Exemple #12
0
 def test_evaluates(self):
     self.assertEqual(maybe_promise(promise(lambda: 10)), 10)
     self.assertEqual(maybe_promise(20), 20)
 def test_evaluates(self):
     self.assertEqual(maybe_promise(promise(lambda: 10)), 10)
     self.assertEqual(maybe_promise(20), 20)