Example #1
0
 def __init__(self, app, schedule=None, max_interval=None, Publisher=None, lazy=False, **kwargs):
     self.app = app
     self.data = maybe_evaluate({} 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()
Example #2
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_evaluate(p[1]), LRUCache)
        self.assertIs(p[2], o)

        self.assertEqual(routes.prepare(o), [o])
Example #3
0
 def _matcher(it, *args, **kwargs):
     for obj in it:
         try:
             answer = getattr(maybe_evaluate(obj), method)(*args, **kwargs)
         except AttributeError:
             pass
         else:
             if answer is not None:
                 return answer
Example #4
0
 def _matcher(it, *args, **kwargs):
     for obj in it:
         try:
             answer = getattr(maybe_evaluate(obj), method)(*args, **kwargs)
         except AttributeError:
             pass
         else:
             if answer is not None:
                 return answer
Example #5
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_evaluate(p[1]), LRUCache)
        self.assertIs(p[2], o)

        self.assertEqual(routes.prepare(o), [o])
Example #6
0
 def __init__(self, app, schedule=None, max_interval=None,
              Publisher=None, lazy=False, **kwargs):
     self.app = app
     self.data = maybe_evaluate({} 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()
Example #7
0
 def _matcher(it, *args, **kwargs):
     for obj in it:
         try:
             meth = getattr(maybe_evaluate(obj), method)
             reply = on_call(meth, *args, **kwargs) if on_call else meth(*args, **kwargs)
         except AttributeError:
             pass
         else:
             if reply is not None:
                 return reply
Example #8
0
 def _matcher(it, *args, **kwargs):
     for obj in it:
         try:
             meth = getattr(maybe_evaluate(obj), method)
             reply = (on_call(meth, *args, **kwargs) if on_call
                      else meth(*args, **kwargs))
         except AttributeError:
             pass
         else:
             if reply is not None:
                 return reply
Example #9
0
 def __init__(
     self, app, schedule=None, max_interval=None, Producer=None, lazy=False, sync_every_tasks=None, **kwargs
 ):
     self.app = app
     self.data = maybe_evaluate({} if schedule is None else schedule)
     self.max_interval = max_interval or app.conf.CELERYBEAT_MAX_LOOP_INTERVAL or self.max_interval
     self.Producer = Producer or app.amqp.Producer
     self._heap = None
     self.sync_every_tasks = app.conf.CELERYBEAT_SYNC_EVERY if sync_every_tasks is None else sync_every_tasks
     if not lazy:
         self.setup_schedule()
Example #10
0
    def test_prepare(self):
        o = object()
        R = [
            {'foo': 'bar'},
            qualname(TestRouter),
            o,
        ]
        p = routes.prepare(R)
        self.assertIsInstance(p[0], routes.MapRoute)
        self.assertIsInstance(maybe_evaluate(p[1]), TestRouter)
        self.assertIs(p[2], o)

        self.assertEqual(routes.prepare(o), [o])
Example #11
0
    def test_prepare(self):
        o = object()
        R = [
            {'foo': 'bar'},
            qualname(TestRouter),
            o,
        ]
        p = routes.prepare(R)
        assert isinstance(p[0], routes.MapRoute)
        assert isinstance(maybe_evaluate(p[1]), TestRouter)
        assert p[2] is o

        assert routes.prepare(o) == [o]
Example #12
0
 def __init__(self, app, schedule=None, max_interval=None,
              Producer=None, lazy=False, sync_every_tasks=None, **kwargs):
     self.app = app
     self.data = maybe_evaluate({} if schedule is None else schedule)
     self.max_interval = (max_interval or
                          app.conf.beat_max_loop_interval or
                          self.max_interval)
     self.Producer = Producer or app.amqp.Producer
     self._heap = None
     self.sync_every_tasks = (
         app.conf.beat_sync_every if sync_every_tasks is None
         else sync_every_tasks)
     if not lazy:
         self.setup_schedule()
Example #13
0
 def __init__(self, app, schedule=None, max_interval=None,
              Producer=None, lazy=False, sync_every_tasks=None, **kwargs):
     self.app = app
     self.data = maybe_evaluate({} if schedule is None else schedule)
     self.max_interval = (max_interval or
                          app.conf.beat_max_loop_interval or
                          self.max_interval)
     self.Producer = Producer or app.amqp.Producer
     self._heap = None
     self.sync_every_tasks = (
         app.conf.beat_sync_every if sync_every_tasks is None
         else sync_every_tasks)
     if not lazy:
         self.setup_schedule()
Example #14
0
 def __init__(self, app, schedule=None, max_interval=None,
              Producer=None, lazy=False, sync_every_tasks=None, **kwargs):
     self.app = app
     self.data = maybe_evaluate({} if schedule is None else schedule)
     self.max_interval = (max_interval or
                          app.conf.CELERYBEAT_MAX_LOOP_INTERVAL or
                          self.max_interval)
     self.Producer = Producer or app.amqp.Producer
     self._heap = None
     self.sync_every_tasks = (
         app.conf.CELERYBEAT_SYNC_EVERY if sync_every_tasks is None
         else sync_every_tasks)
     if not lazy:
         self.setup_schedule()
Example #15
0
 def test_evaluates(self):
     self.assertEqual(maybe_evaluate(lazy(lambda: 10)), 10)
     self.assertEqual(maybe_evaluate(20), 20)
Example #16
0
def test_maybe_evaluate(obj, expected):
    assert maybe_evaluate(obj) == expected
Example #17
0
def test_maybe_evaluate(obj, expected):
    assert maybe_evaluate(obj) == expected
 def test_evaluates(self):
     self.assertEqual(maybe_evaluate(lazy(lambda: 10)), 10)
     self.assertEqual(maybe_evaluate(20), 20)