コード例 #1
0
def process_background_tasks():
    """Discover and run background tasks in the common app."""
    for path, func in TASKS.items():
        import_module(path)

        pending_tasks = Task.objects.filter(task_name='.'.join([path, func]))

        for task in pending_tasks:
            task_manager.run_task(task)
コード例 #2
0
def mocked_run_task(name, args=None, kwargs=None):
    """
    We mock tasks.run_task to give other threads some time to update the database.

    Otherwise we run into a locked database.
    """
    val = tasks.run_task(name, args, kwargs)
    if app_settings.BACKGROUND_TASK_RUN_ASYNC:
        time.sleep(1)
    return val
コード例 #3
0
def mocked_run_task(name, args=None, kwargs=None):
    """
    We mock tasks.run_task to give other threads some time to update the database.

    Otherwise we run into a locked database.
    """
    val = tasks.run_task(name, args, kwargs)
    if app_settings.BACKGROUND_TASK_RUN_ASYNC:
        time.sleep(1)
    return val
コード例 #4
0
    def test_run_task(self):
        tasks.run_task(self.proxy.name, [], {})
        self.assertEqual(((), {}), _recorded.pop())

        tasks.run_task(self.proxy.name, ['hi'], {})
        self.assertEqual((('hi', ), {}), _recorded.pop())

        tasks.run_task(self.proxy.name, [], {'kw': 1})
        self.assertEqual(((), {'kw': 1}), _recorded.pop())
コード例 #5
0
    def test_run_task(self):
        tasks.run_task(self.proxy.name, [], {})
        self.assertEqual(((), {}), _recorded.pop())

        tasks.run_task(self.proxy.name, ['hi'], {})
        self.assertEqual((('hi',), {}), _recorded.pop())

        tasks.run_task(self.proxy.name, [], {'kw': 1})
        self.assertEqual(((), {'kw': 1}), _recorded.pop())
コード例 #6
0
ファイル: lilspikey_tests.py プロジェクト: ccavxx/py-search
 def test_run_task(self):        tasks.run_task(self.proxy.name, [], {}) self.assertEqual(((), {}), _recorded.pop())
コード例 #7
0
ファイル: lilspikey_tests.py プロジェクト: ccavxx/py-search
class TestTaskProxy(unittest.TestCase):
 def setUp(self): super(TestTaskProxy, self).setUp() self.proxy = tasks.background()(record_task)
 def test_run_task(self):        tasks.run_task(self.proxy.name, [], {}) self.assertEqual(((), {}), _recorded.pop())
        tasks.run_task(self.proxy.name, ['hi'], {}) self.assertEqual((('hi',), {}), _recorded.pop())
        tasks.run_task(self.proxy.name, [], {'kw': 1}) self.assertEqual(((), {'kw': 1}), _recorded.pop())