While reading through the rq
docs, I notice that there are some arguments that you can pass to rq worker
when starting the worker
Example:
rq worker --worker-class 'foo.bar.MyWorker'
Argument list includes
--worker-class
or -w
: RQ Worker class to use (e.g rq worker --worker-class 'foo.bar.MyWorker')--job-class
or -j
: RQ Job class to use.--queue-class
: RQ Queue class to use.What are worker classes, job classes and queue classes, and when do you utilize them?
A worker is a Python process that typically runs in the background and exists solely as a work horse to perform lengthy or blocking tasks that you don't want to perform inside web processes.
RQ, also known as Redis Queue, is a Python library that allows developers to enqueue jobs to be processed in the background with workers. The RQ workers will be called when it's time to execute the queue in the background.
It's just inheritance of classes ( Worker from rq for example )
Let it as base_worker.py
import pseudo_realy_necessery_library_for_every_job
from rq import Worker as BaseClass
class Worker(BaseClass):
def __init__(self, queues=None, *args, **kwargs):
u'''
Constructor.
Accepts the same arguments as the constructor of
``rq.worker.Worker``.
'''
super().__init__(queues, *args, **kwargs)
and u can run
rq worker --worker-class='base_worker.Worker'
In my case I have exclude reloading library for every new job
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With