Beispiel #1
0
    def testLeaseAndFinish(self):
        """Tests leasing tasks and finishing them."""
        task_ids = []
        for i in xrange(10):
            next_id = work_queue.add(TEST_QUEUE,
                                     payload={
                                         'foo': i,
                                         'bar': 5.5,
                                         'baz': 'banana'
                                     })
            task_ids.append(next_id)
        db.session.commit()

        item = queue_worker.RemoteQueueWorkflow(TEST_QUEUE,
                                                TestQueueWorkflow,
                                                max_tasks=1,
                                                wait_seconds=0.01)
        item.root = True
        self.coordinator.input_queue.put(item)
        time.sleep(2)
        item.stop()
        self.coordinator.wait_one()

        db.session.flush()
        for task_id in task_ids:
            found = work_queue.WorkQueue.query.get((task_id, TEST_QUEUE))
            self.assertEquals(work_queue.WorkQueue.DONE, found.status)
Beispiel #2
0
def register(coordinator):
    """Registers this module as a worker with the given coordinator."""
    assert FLAGS.pdiff_threads > 0
    assert FLAGS.queue_server_prefix

    item = queue_worker.RemoteQueueWorkflow(
        constants.PDIFF_QUEUE_NAME,
        DoPdiffQueueWorkflow,
        max_tasks=FLAGS.pdiff_threads,
        wait_seconds=FLAGS.pdiff_wait_seconds)
    item.root = True
    coordinator.input_queue.put(item)
def register(coordinator):
    """Registers this module as a worker with the given coordinator."""
    assert FLAGS.phantomjs_binary
    assert FLAGS.phantomjs_script
    assert FLAGS.capture_threads > 0
    assert FLAGS.queue_server_prefix

    item = queue_worker.RemoteQueueWorkflow(
        constants.CAPTURE_QUEUE_NAME,
        DoCaptureQueueWorkflow,
        max_tasks=FLAGS.capture_threads,
        wait_seconds=FLAGS.capture_wait_seconds)
    item.root = True
    coordinator.input_queue.put(item)
Beispiel #4
0
def register(coordinator):
    """Registers this module as a worker with the given coordinator."""

    if FLAGS.phantomjs_script:
        utils.verify_binary('phantomjs_binary', ['--version'])
        assert os.path.exists(FLAGS.phantomjs_script)
    else:
        utils.verify_binary('capture_binary', ['--version'])
        assert FLAGS.capture_script
        assert os.path.exists(FLAGS.capture_script)

    assert FLAGS.capture_threads > 0
    assert FLAGS.queue_server_prefix

    item = queue_worker.RemoteQueueWorkflow(
        constants.CAPTURE_QUEUE_NAME,
        DoCaptureQueueWorkflow,
        max_tasks=FLAGS.capture_threads,
        wait_seconds=FLAGS.capture_wait_seconds)
    item.root = True
    coordinator.input_queue.put(item)