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