简体   繁体   中英

Redis Queue Kill Job using JOB-ID

I used Python Flask+Redis and I queued the jobs at redis queue using the below code:

 with Connection(redis.from_url("redis://localhost:6379")):
            queue = Queue()
            task = queue.enqueue(self.redis_method, job_timeout=86400, result_ttl=604800, failure_ttl=604800)
            response_object = {"status": "success", "data": {"task_id": task.get_id()}}
            return response_object

Jobs are getting queued and execution starts and I get Job-id for queued job. And used below code to kill Job but the execution doesn't stop even after executing below code

cancel_job(job_id=job_id,connection= redis.from_url("redis://localhost:6379"))

Any help appreciated. Thanks in Advance~

cancel_job removes the job from the queue. If it's already in the execution process you have to kill the worker.

from rq.command import send_kill_horse_command

send_kill_horse_command(connection, worker_name) 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM