Search code examples
python-rq

re-use an instance in an RQ worker?


I have a class that does a complex calculation for me. The actual calculation does not take that long, but getting an instance of the class takes about a second. (It reads in a bunch of large-ish data files.)

Is there a way that I can create an instance of this class, and then have my RQ worker re-use it, rather than having to re-initialize it for each job that I execute?


Solution

  • duh. I missed it in the documentation: http://python-rq.org/docs/workers/

    Under "performance notes", it even gives sample code to help with this problem