[PYTHON] Even if you cancel or delete the job in the queue, the process running on the worker does not stop (2)

background

I found a better way than the previous article

Set to RedisClient when erasing a job

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)

Confirmed on the processing side

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

reference

Recommended Posts

Even if you cancel or delete the job in the queue, the process running on the worker does not stop (2)
Even if you cancel or delete the job in the queue, the process running on the worker does not stop (2)
python> does not include the letters mm> if "mm" not in text: / print "not including mm"
[Learning memo] Create if the directory does not exist / Get the files in the directory
python> does not include the letters mm> if "mm" not in text: / print "not including mm"
[Learning memo] Create if the directory does not exist / Get the files in the directory