示例#1
0
 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()
示例#2
0
 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()
示例#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()
示例#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'))
示例#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'))
示例#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'))
示例#7
0
 def test_no_flag(self):
     """With no flag set, result is False."""
     self.assertFalse(celery_enabled('foo'))
示例#8
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'))
示例#9
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'))
示例#10
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'))
示例#11
0
 def test_no_flag(self):
     """With no flag set, result is False."""
     self.assertFalse(celery_enabled('foo'))