I found a better way than the previous article
from django_rq import get_queue
import os
import signal
q = get_queue()
job_id = ***
job = q.fetch_job(job_id)
job.connection.set(job.key + b':canceled', True, ex=30)
from rq import get_current_job
def processing():
job = get_current_job()
for item in items:
if job.connection.get(job.key + b':canceled'):
break
Recommended Posts