I have a Python Flask app on Heroku that serves web pages but also allows certain tasks to be launched which I believe would be best structured as background tasks. As such, I've followed the Heroku rq tutorial to set up background tasks. My Procfile looks like this:

web: python app.py
worker: python worker.py

However, my processes are currently scaled web=1 worker=0. Given that this background process won't be run very often, it doesn't seem sensible to me to provision an entire dyno for it and then pay the $34/month for something that small.

Question:

  • If I leave the worker process declared in my Procfile but keep the scaling at web=1 worker=0, will my queued processes eventually be run on my available web dyno? Or will the queued processes never run?
  • If the queued processes will never run, is there another way to do this short of, for example, using twisted in my web app to run the tasks asynchronously?

Additional Information

worker.py looks like this:

import os
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()

The logic in the main app that enqueues a process looks like this:

from rq import Queue
from worker import conn
q = Queue(connection=conn)

q.enqueue(myfunction, myargument)
Edit
Report