8

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?

Nyxynyx
  • 61,411
  • 155
  • 482
  • 830

1 Answers1

2

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

rrretry
  • 103
  • 1
  • 7