Forums

Can I use a Redis worker?

My Plotly Dash app is a bioinformatics app that runs algos like Needleman-Wunsch and Smith-Waterman (dynamic programming sequence alignment). I used to have my app on Heroku and there I was able to have a file called worker.py that would do the alignment work while my app.py would serve requests (I think that's the reason why I added it, ie. I did not tend to my Heroku app for over a year and just realized it was deleted).

Anyways, is this possible on pythonanywhere?

I was just able to run it fine locally after installing redis server on WSL2.

My worker.py

import os
from Bio import pairwise2
from Bio import Align

import redis
from rq import Worker, Queue, Connection

listen = ['high', 'default', 'low']

redis_url = os.getenv('REDISTOGO_URL', 'redis://localhost:6379')

conn = redis.from_url(redis_url)

if __name__ == '__main__':
    with Connection(conn):
        worker = Worker(map(Queue, listen))
        worker.work()

We don't support Redis on PythonAnywhere -- you could try using an external Redis instance, see this help page.