Change print statement to print function in docs (#985)

main
Aly Sivji 6 years ago committed by Selwin Ong
parent 6a376191d9
commit a2f245a0c1

@ -38,11 +38,11 @@ q = Queue(connection=redis_conn) # no args implies the default queue
# Delay execution of count_words_at_url('http://nvie.com') # Delay execution of count_words_at_url('http://nvie.com')
job = q.enqueue(count_words_at_url, 'http://nvie.com') job = q.enqueue(count_words_at_url, 'http://nvie.com')
print job.result # => None print(job.result) # => None
# Now, wait a while, until the worker is finished # Now, wait a while, until the worker is finished
time.sleep(2) time.sleep(2)
print job.result # => 889 print(job.result) # => 889
{% endhighlight %} {% endhighlight %}
If you want to put the work on a specific queue, simply specify its name: If you want to put the work on a specific queue, simply specify its name:
@ -107,7 +107,7 @@ redis_conn = Redis()
q = Queue(connection=redis_conn) q = Queue(connection=redis_conn)
# Getting the number of jobs in the queue # Getting the number of jobs in the queue
print len(q) print(len(q))
# Retrieving jobs # Retrieving jobs
queued_job_ids = q.job_ids # Gets a list of job IDs from the queue queued_job_ids = q.job_ids # Gets a list of job IDs from the queue
@ -160,7 +160,7 @@ def add(x, y):
job = add.delay(3, 4) job = add.delay(3, 4)
time.sleep(1) time.sleep(1)
print job.result print(job.result)
{% endhighlight %} {% endhighlight %}

@ -20,7 +20,7 @@ from rq import get_current_job
def add(x, y): def add(x, y):
job = get_current_job() job = get_current_job()
print 'Current job: %s' % (job.id,) print('Current job: %s' % (job.id,))
return x + y return x + y
{% endhighlight %} {% endhighlight %}
@ -40,7 +40,7 @@ def add(x, y):
job = get_current_job() job = get_current_job()
job.meta['handled_by'] = socket.gethostname() job.meta['handled_by'] = socket.gethostname()
job.save_meta() job.save_meta()
# do more work # do more work
time.sleep(1) time.sleep(1)
return x + y return x + y
@ -65,8 +65,8 @@ job = q.enqueue(count_words_at_url, 'http://nvie.com', ttl=43)
## Failed Jobs ## Failed Jobs
If a job fails and raises an exception, the worker will put the job in a failed job queue. If a job fails and raises an exception, the worker will put the job in a failed job queue.
On the Job instance, the `is_failed` property will be true. To fetch all failed jobs, scan On the Job instance, the `is_failed` property will be true. To fetch all failed jobs, scan
through the `get_failed_queue()` queue. through the `get_failed_queue()` queue.
{% highlight python %} {% highlight python %}
@ -92,4 +92,4 @@ fq.requeue(job.id)
assert fq.count == 0 assert fq.count == 0
assert Queue('fake').count == 1 assert Queue('fake').count == 1
{% endhighlight %} {% endhighlight %}

Loading…
Cancel
Save