What are Queue classes, Worker Classes, Job Classes in Python rq package
Asked Answered
O

1

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?

Ovovitellin answered 20/6, 2018 at 19:37 Comment(0)
O
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

Obloquy answered 15/6, 2019 at 5:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.