A wrapper to start RQ worker as a new process.

    :param worker_instance: RQ's worker instance
    :param pid_path: A file to check if the worker
        is running or not

def worker_wrapper(worker_instance, pid_path):
    """
    A wrapper to start RQ worker as a new process.

    :param worker_instance: RQ's worker instance
    :param pid_path: A file to check if the worker
        is running or not
    """
    def exit_handler(*args):
        """
        Remove pid file on exit
        """
        if len(args) > 0:
            print("Exit py signal {signal}".format(signal=args[0]))
        remove(pid_path)

    atexit.register(exit_handler)
    signal.signal(signal.SIGINT, exit_handler)
    signal.signal(signal.SIGTERM, exit_handler)

    worker_instance.work()

    # Remove pid file if the process can not catch signals
    exit_handler(2)