from rq import Queue
from redis import Redis
import multiprocessing as mp
from rq import Worker

class Worker(Worker):
    """
    The class extends and configures the rq worker into a new process.
    """
    def __init__(self, name: str, config: dict, q: Queue, r: Redis) -> None:
        super().__init__([q], connection=r, name=name)
        self.config = config

        # TODO: Use self.config for further customization of worker

    def run(self):
        mp.Process(name=f"Worker ({self.name})", target=lambda: self.work()).start()