سؤال

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?

هل كانت مفيدة؟

المحلول

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top