Forums

redis queue (RQ) with redislite

Hello, I'm following the offficial example to try out rq+redislite on PythonAnywhere.

Setting up a redislite queue like this works great:

from redislite import Redis                                                                                                                                         
from rq import Queue                                                                                                                                                
from rqjob import count_words_at_url                                
q = Queue(connection=Redis('RQ_example.rdb'))
result1 = q.enqueue(count_words_at_url, "https://google.com")
result2 = q.enqueue(count_words_at_url, "https://yahoo.com")                                                                                                         
len(q)                                                                                                                                                              
>>>  2

But running an rq worker on that queue (in a separate bash console) is not connecting:

$ rq worker
>>> Error 111 connecting to localhost:6379. Connection refused.
$ rq worker -u unix:///tmp/tmp_5qy5x5f/redis.socket
>>> Error 111 connecting to unix socket: /tmp/tmp_5qy5x5f/redis.socket. Connection refused.

The first command is what the redislite documentation suggests to do, while the second works on my local computer. I might be missing something PythonAnywhere - specific.

For information, that socket file is the one specified in RQ_example.rdb.settings and it is owned by me and has access rights 700. Both rq and redislite versions are the same on PA and my machine:

$ rq --version
rq, version 1.1.0
$ pip list | grep redislite
redislite                5.0.142319

Has anyone gotten rq to successfully work with redislite on PythonAnywhere?

I got the rq worker to connect if I used the same bash console where I populated the queue. Not sure why, maybe some PA abstraction layer explains it.

However: If this persists, I don't think I can fulfil my dream of using rq in an always-on task (without configuring a third-party host for redis) ...

Unfortunately I don't think it would work right now :-( We suggest redislite for caching in websites, because all of the workers for a website are on the same machine and in the same network namespace, but consoles (in general) are separate, so they can't communicate that way. We do plan to provide internally-addressable servers using always-on tasks in the near future, but we don't have a timeline right now.

Thanks, Giles. Well, I hope either this or Redis support lands in the near future :D I'll have to try a third-party host for Redis now, but for prototype systems like we're building at the moment, I'd sure prefer I could stay within the realms of PythonAnywhere.

Understood :-)

Please, are there any plans of doing this now.

No

I am also interested in doing this. +1

Noted

It's been 3 years, I'm still interested. Any updates on internally-addressable servers?

Unfortunately not. However, there are good providers of redis out there that will work from paid PythonAnywhere accounts -- Redis Labs are pretty popular, and if you get an instance in the AWS us-east-1 datacenter then it will be close to our servers in network terms.

Ok. I have exactly that. How would you connect to Redis Labs without blocking port 443 for regular requests?

Could you provide some more details about what is concerning you?

Never mind, I believe the answer to my question is to use a subdomain that directs redis traffic to something like “redis.example.com” on port 443.

I'm not sure that's right, but connecting to Redis Labs should not have any effect at all on whether you can handle incoming requests on port 443, if that's what you're asking. Redis Labs provide a Redis server on some particular port (probably 6379), but that won't affect port 443.