예제 #1
0
파일: test_utils.py 프로젝트: f0cker/rq
 def test_get_call_string(self):
     """Ensure a case, when func_name, args and kwargs are not None, works properly"""
     cs = get_call_string("f", ('some', 'args', 42), {
         "key1": "value1",
         "key2": True
     })
     assert cs == "f('some', 'args', 42, key1='value1', key2=True)"
예제 #2
0
파일: test_utils.py 프로젝트: f0cker/rq
 def test_get_call_string_with_max_length(self):
     """Ensure get_call_string works properly when max_length is provided"""
     func_name = "f"
     args = (1234, 12345, 123456)
     kwargs = {"len4": 1234, "len5": 12345, "len6": 123456}
     cs = get_call_string(func_name, args, kwargs, max_length=5)
     assert cs == "f(1234, 12345, 12345..., len4=1234, len5=12345, len6=12345...)"
예제 #3
0
파일: cli.py 프로젝트: luisbc92/rq
def enqueue(cli_config, queue, timeout, result_ttl, ttl, failure_ttl,
            description, depends_on, job_id, at_front, retry_max,
            retry_interval, schedule_in, schedule_at, quiet, serializer,
            function, arguments, **options):
    """Enqueues a job from the command line"""
    args, kwargs = parse_function_args(arguments)
    function_string = get_call_string(function, args, kwargs)
    description = description or function_string

    retry = None
    if retry_max > 0:
        retry = Retry(retry_max, retry_interval)

    schedule = parse_schedule(schedule_in, schedule_at)

    with Connection(cli_config.connection):
        queue = cli_config.queue_class(queue, serializer=serializer)

        if schedule is None:
            job = queue.enqueue_call(function, args, kwargs, timeout,
                                     result_ttl, ttl, failure_ttl, description,
                                     depends_on, job_id, at_front, None, retry)
        else:
            job = queue.create_job(function, args, kwargs, timeout, result_ttl,
                                   ttl, failure_ttl, description, depends_on,
                                   job_id, None, JobStatus.SCHEDULED, retry)
            queue.schedule_job(job, schedule)

    if not quiet:
        click.echo('Enqueued %s with job-id \'%s\'.' %
                   (blue(function_string), job.id))