Flask-RQ2 icon indicating copy to clipboard operation
Flask-RQ2 copied to clipboard

Rq retry

Open amks1 opened this issue 3 years ago • 2 comments

Added support for the Retry() class of RQ. Tested working.

amks1 avatar Feb 20 '22 09:02 amks1

@amks1 It's great that you have retry added. I tried the retry branch and found that it does not support try with interval argument.

retry=Retry(max=3, interval=10)

I checked rq docs and found that --with-scheduler parameter should be used when start a worker, so I suggest you add it to worker command. Thanks.

liqb avatar Oct 20 '22 04:10 liqb

Not working for me with redis. I added retry=Retry(max=3, interval=[1, 1, 1]) to enqueue method

My 'on_failure' method is something like this; on_failure=report_failure,

def report_failure(job, connection, type, value, traceback):
    # 'value' is the error msg. thrown by the error function
    logger.info("entered report_failure")
    logger.info(f"{job.retries_left=}")
    logger.info(f"{value=}")
    if job.retries_left:
        # redo
        logger.info("inside if")
        logger.info(
            f"{job.retries_left} retries left. Debug msg. '{value}'",
            extra={"clp_fields": {
                "chainId": job.id,
                "meta": job.meta,
                "process": "worker"
            }},
        )
        return
    # last try
    logger.info("outside if")
    logger.info(f"{job.args[0]['input']=}")
    # log final error
    logger.error(
        f"All retries failed. Error msg. '{value}'",
        extra={"clp_fields": {
            "chainId": job.id,
            "meta": job.meta,
            "process": "worker",
        }},
    )

The code only enters the report_failure 1 time and then don't do anything after that, it is supposed to call the retry worker method automatically. This was working with python rq library.

mllife avatar Nov 23 '23 04:11 mllife