Browse Source

setting for optionally syncing on every scheduled task execution

chrisclark 11 years ago
parent
commit
427636a131
2 changed files with 3 additions and 2 deletions
  1. 2 1
      celery/beat.py
  2. 1 1
      celery/tests/app/test_beat.py

+ 2 - 1
celery/beat.py

@@ -220,7 +220,8 @@ class Scheduler(object):
 
 
     def should_sync(self):
     def should_sync(self):
         return (not self._last_sync or
         return (not self._last_sync or
-                (monotonic() - self._last_sync) > self.sync_every)
+                 (monotonic() - self._last_sync) > self.sync_every) or \
+                 self.app.conf.CELERY_SYNC_EVERY_SCHEDULED_TASK
 
 
     def reserve(self, entry):
     def reserve(self, entry):
         new_entry = self.schedule[entry.name] = next(entry)
         new_entry = self.schedule[entry.name] = next(entry)

+ 1 - 1
celery/tests/app/test_beat.py

@@ -162,7 +162,7 @@ class test_Scheduler(AppCase):
         scheduler.apply_async(scheduler.Entry(task=foo.name, app=self.app))
         scheduler.apply_async(scheduler.Entry(task=foo.name, app=self.app))
         self.assertTrue(foo.apply_async.called)
         self.assertTrue(foo.apply_async.called)
 
 
-    def test_apply_async_should_not_sync(self):
+    def test_should_sync(self):
 
 
         @self.app.task(shared=False)
         @self.app.task(shared=False)
         def not_sync():
         def not_sync():