def run(self, _no_init=False):
     if not _no_init:
         task_init('run_missing_ready')
     with TransactionFreeOperation():
         count = 0
         for job in find_missing_ready(BranchScanJob):
             if not celery_enabled(job.__class__.__name__):
                 continue
             job.celeryCommitHook(True)
             count += 1
         info('Scheduled %d missing jobs.', count)
         transaction.commit()
 def run(self, _no_init=False):
     if not _no_init:
         task_init('run_missing_ready')
     with TransactionFreeOperation():
         count = 0
         for job in find_missing_ready(BranchScanJob):
             if not celery_enabled(job.__class__.__name__):
                 continue
             job.celeryCommitHook(True)
             count += 1
         info('Scheduled %d missing jobs.', count)
         transaction.commit()
Beispiel #3
0
def run_missing_ready(_no_init=False):
    """Task to run any jobs that are ready but not scheduled.

    Currently supports only BranchScanJob.
    :param _no_init: For tests.  If True, do not perform the initialization.
    """
    if not _no_init:
        task_init('run_missing_ready')
    with TransactionFreeOperation():
        count = 0
        for job in find_missing_ready(BranchScanJob):
            if not celery_enabled(job.__class__.__name__):
                continue
            job.celeryCommitHook(True)
            count += 1
        info('Scheduled %d missing jobs.', count)
        transaction.commit()
Beispiel #4
0
 def test_substring(self):
     """A substring of an enabled class does not match."""
     self.useFixture(
         FeatureFixture({'jobs.celery.enabled_classes': 'foobar'}))
     self.assertFalse(celery_enabled('bar'))
Beispiel #5
0
 def test_matching_flag(self):
     """A matching flag returns True."""
     self.useFixture(
         FeatureFixture({'jobs.celery.enabled_classes': 'foo bar'}))
     self.assertTrue(celery_enabled('foo'))
     self.assertTrue(celery_enabled('bar'))
Beispiel #6
0
 def test_non_matching_flag(self):
     """A non-matching flag returns false."""
     self.useFixture(
         FeatureFixture({'jobs.celery.enabled_classes': 'foo bar'}))
     self.assertFalse(celery_enabled('baz'))
     self.assertTrue(celery_enabled('bar'))
Beispiel #7
0
 def test_no_flag(self):
     """With no flag set, result is False."""
     self.assertFalse(celery_enabled('foo'))
 def test_substring(self):
     """A substring of an enabled class does not match."""
     self.useFixture(FeatureFixture(
         {'jobs.celery.enabled_classes': 'foobar'}))
     self.assertFalse(celery_enabled('bar'))
 def test_non_matching_flag(self):
     """A non-matching flag returns false."""
     self.useFixture(FeatureFixture(
         {'jobs.celery.enabled_classes': 'foo bar'}))
     self.assertFalse(celery_enabled('baz'))
     self.assertTrue(celery_enabled('bar'))
 def test_matching_flag(self):
     """A matching flag returns True."""
     self.useFixture(FeatureFixture(
         {'jobs.celery.enabled_classes': 'foo bar'}))
     self.assertTrue(celery_enabled('foo'))
     self.assertTrue(celery_enabled('bar'))
 def test_no_flag(self):
     """With no flag set, result is False."""
     self.assertFalse(celery_enabled('foo'))