0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

queueのjobをcancel、deleteしてもworkerで動いている処理は止まらない(2)

Posted at

背景

前回記事より良い方法見つけた

ジョブを消す時にRedisClientにset

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 処理():
  job = get_current_job()
  for item in items:
    if job.connection.get(job.key + b':canceled'):
      break

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?