Beispiel #1
0
    def test_rqinfo_can_choose_queue(self):
        parser = rqinfo.setup_parser()
        args = parser.parse_args(self.base_arguments + ["B"])

        setup_default_arguments(args, {})
        setup_redis(args)

        output = self.capture_stdout(rqinfo.show_queues, args)

        connections.use_connection(self.testconn)

        expected_output = ["queue B 1"]
        self.assertEqual(output.splitlines(), expected_output)
Beispiel #2
0
    def test_rqinfo_defaults_to_all_queues(self):
        parser = rqinfo.setup_parser()
        args = parser.parse_args(self.base_arguments)

        setup_default_arguments(args, {})
        setup_redis(args)  # This uses use_connection and clears self.testconn from the stack

        output = self.capture_stdout(rqinfo.show_queues, args)

        connections.use_connection(self.testconn)

        expected_output = set(["queue B 1", "queue C 1", "queue A 1"])
        self.assertEqual(set(output.splitlines()), expected_output)
Beispiel #3
0
def run_scheduler():
    parser = argparse.ArgumentParser(description='RQ cron')
    parser.add_argument('--config', dest='config', action='store',
                        required=True, help='path to config file')

    args = parser.parse_args()
    config = json.load(open(vars(args)["config"]))
    use_connection(Redis(config["redis"]))
    try:
        os.mkdir(config["status_dir"])
    except OSError:
        pass

    scheduler = RQCron(config["status_dir"], time.time, time.sleep)
    for job in config["jobs"]:
        scheduler.repeat(job.get("cron") or job["interval"], 1, _task(config, job), 
                         name=job['name'])

    logger.debug("running")
    scheduler.run()