I’m pretty new to Redis queuing job task. I tried to do some function on the queue by using Redis To Go Add-on. But after I push some task on queue it seems to disappear.
Here is my code
import Flask
import redis
from rq import Queue
REDIS_URL = os.getenv('REDISTOGO_URL', None)
if REDIS_URL!=None:
r = redis.from_url(REDIS_URL)
else:
r = redis.Redis()
q = Queue(connection=r)
def function(pam1):
print("Checkpoint1")
return 0
@main.route('/name', methods=['GET', 'POST'])
def displayname():
job = q.enqueue(function, pam1=0)
return job.id
Additional info on queue: There still give the job id eg.7344337b-cca0-442a-b43a-abcdc88f012c.
but no sign of “Checkpoint1” on heroku log at all.
2
Answers
Thanks to @v25. The real reason that Redis not responds because I don't have a WORKER. After get thu see the Heroku guide on launching a worker now my problem solved.
I’m not sure about Heroku’s logging implementation, but assuming you’re looking at the wrong log (or something) you could try this…
Instead of printing ‘Checkpoint’, increment the value of a custom redis key:
Then create a route where you can check this value:
Now enqueue a few jobs, and check the
/show_count
route to make sure it has incremented accordingly.