I want to enqueue the RQ task, to complete a task, suppose it takes around 10 minutes, Now i want to pause any task if it continues for 5 minutes and start another task and after another 5 minutes and i want to pause the second task and start the 3rd one. Eventually, i plan to resume all the tasks and finish them
r = redis.Redis(host='localhost')
q = Queue(connection=r)
app = FastAPI()
@app.get("/add")
async def add_task(url: str):
task = q.enqueue(count_words,
job_timeout='2h',
result_ttl=1000,
args=(url,))
return JSONResponse(content=success_return({
"length_queue": len(q),
"task_id": task.id
}))
Here, the count_words just sleeps for 10 minutes and return the content of the url