prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Please make the rqrequeue service quieter
  ## Description
  
  The rqrequeue service feels compelled to report that it has nothing to do, resulting in an endless stream of "No interrupted jobs found in started job registry." messages. This is not helpful during normal operations, and annoying during development.
  
  </issue>
  <code>
  [start of securedrop/worker.py]
  1 import logging
  2 import os
  3 from typing import Optional, List
  4 
  5 from redis import Redis
  6 from rq.queue import Queue
  7 from rq.worker import Worker, WorkerStatus
  8 from rq.exceptions import InvalidJobOperation, NoSuchJobError
  9 from rq.registry import StartedJobRegistry
  10 
  11 from sdconfig import config
  12 
  13 
  14 def create_queue(name=None, timeout=3600):
  15     # type: (str, int) -> Queue
  16     """
  17     Create an rq ``Queue`` named ``name`` with default timeout ``timeout``.
  18 
  19     If ``name`` is omitted, ``config.RQ_WORKER_NAME`` is used.
  20     """
  21     if name is None:
  22         name = config.RQ_WORKER_NAME
  23     q = Queue(name=name, connection=Redis(), default_timeout=timeout)
  24     return q
  25 
  26 
  27 def rq_workers(queue=None):
  28     # type: (Queue) -> List[Worker]
  29     """
  30     Returns the list of current rq ``Worker``s.
  31     """
  32 
  33     return Worker.all(connection=Redis(), queue=queue)
  34 
  35 
  36 def worker_for_job(job_id):
  37     # type: (str) -> Optional[Worker]
  38     """
  39     If the job is being run, return its ``Worker``.
  40     """
  41     for worker in rq_workers():
  42         # If the worker process no longer exists, skip it. From "man 2
  43         # kill": "If sig is 0, then no signal is sent, but existence
  44         # and permission checks are still performed; this can be used
  45         # to check for the existence of a process ID or process group
  46         # ID that the caller is permitted to signal."
  47         try:
  48             os.kill(worker.pid, 0)
  49         except OSError:
  50             continue
  51 
  52         # If it's running and working on the given job, return it.
  53         if worker.state == WorkerStatus.BUSY and job_id == worker.get_current_job_id():
  54             return worker
  55     return None
  56 
  57 
  58 def requeue_interrupted_jobs(queue_name=None):
  59     # type: (str) -> None
  60     """
  61     Requeues jobs found in the given queue's started job registry.
  62 
  63     Only restarts those that aren't already queued or being run.
  64 
  65     When rq starts a job, it records it in the queue's started job
  66     registry. If the server is rebooted before the job completes, the
  67     job is not automatically restarted from the information in the
  68     registry. For tasks like secure deletion of files, this means that
  69     information thought to be deleted is still present in the case of
  70     seizure or compromise. We have manage.py tasks to clean such files
  71     up, but this utility attempts to reduce the need for manual
  72     intervention by automatically resuming interrupted jobs.
  73 
  74     This function is predicated on a risky assumption: that all jobs
  75     are idempotent. At time of writing, we use rq for securely
  76     deleting submission files and hashing submissions for the ETag
  77     header. Both of these can be safely repeated. If we add rq tasks
  78     that cannot, this function should be improved to omit those.
  79     """
  80     queue = create_queue(queue_name)
  81     started_job_registry = StartedJobRegistry(queue=queue)
  82 
  83     queued_job_ids = queue.get_job_ids()
  84     logging.debug("queued jobs: {}".format(queued_job_ids))
  85     started_job_ids = started_job_registry.get_job_ids()
  86     logging.debug("started jobs: {}".format(started_job_ids))
  87     job_ids = [j for j in started_job_ids if j not in queued_job_ids]
  88     logging.debug("candidate job ids: {}".format(job_ids))
  89 
  90     if not job_ids:
  91         logging.info("No interrupted jobs found in started job registry.")
  92 
  93     for job_id in job_ids:
  94         logging.debug("Considering job %s", job_id)
  95         try:
  96             job = started_job_registry.job_class.fetch(job_id, started_job_registry.connection)
  97         except NoSuchJobError as e:
  98             logging.error(
  99                 "Could not find details for job %s: %s", job_id, e
  100             )
  101             continue
  102 
  103         logging.debug(
  104             "Job %s enqueued at %s, started at %s", job_id, job.enqueued_at, job.started_at
  105         )
  106 
  107         worker = worker_for_job(job_id)
  108         if worker:
  109             logging.info(
  110                 "Skipping job %s, which is already being run by worker %s", job_id, worker.key
  111             )
  112             continue
  113 
  114         logging.info("Requeuing job %s", job)
  115 
  116         try:
  117             started_job_registry.remove(job)
  118         except InvalidJobOperation as e:
  119             logging.error("Could not remove job %s from started job registry: %s", job, e)
  120             continue
  121 
  122         try:
  123             queue.enqueue_job(job)
  124             logging.debug("Job now enqueued at %s, started at %s", job.enqueued_at, job.started_at)
  125         except Exception as e:
  126             logging.error("Could not requeue job %s: %s", job, e)
  127             continue
  128
  [end of securedrop/worker.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/securedrop/worker.py b/securedrop/worker.py
  --- a/securedrop/worker.py
  +++ b/securedrop/worker.py
  @@ -88,7 +88,7 @@
       logging.debug("candidate job ids: {}".format(job_ids))
   
       if not job_ids:
  -        logging.info("No interrupted jobs found in started job registry.")
  +        logging.debug("No interrupted jobs found in started job registry.")
   
       for job_id in job_ids:
           logging.debug("Considering job %s", job_id)
  
verification_info: {"golden_diff": "diff --git a/securedrop/worker.py b/securedrop/worker.py\n--- a/securedrop/worker.py\n+++ b/securedrop/worker.py\n@@ -88,7 +88,7 @@\n     logging.debug(\"candidate job ids: {}\".format(job_ids))\n \n     if not job_ids:\n-        logging.info(\"No interrupted jobs found in started job registry.\")\n+        logging.debug(\"No interrupted jobs found in started job registry.\")\n \n     for job_id in job_ids:\n         logging.debug(\"Considering job %s\", job_id)\n", "issue": "Please make the rqrequeue service quieter\n## Description\r\n\r\nThe rqrequeue service feels compelled to report that it has nothing to do, resulting in an endless stream of \"No interrupted jobs found in started job registry.\" messages. This is not helpful during normal operations, and annoying during development.\n", "before_files": [{"content": "import logging\nimport os\nfrom typing import Optional, List\n\nfrom redis import Redis\nfrom rq.queue import Queue\nfrom rq.worker import Worker, WorkerStatus\nfrom rq.exceptions import InvalidJobOperation, NoSuchJobError\nfrom rq.registry import StartedJobRegistry\n\nfrom sdconfig import config\n\n\ndef create_queue(name=None, timeout=3600):\n    # type: (str, int) -> Queue\n    \"\"\"\n    Create an rq ``Queue`` named ``name`` with default timeout ``timeout``.\n\n    If ``name`` is omitted, ``config.RQ_WORKER_NAME`` is used.\n    \"\"\"\n    if name is None:\n        name = config.RQ_WORKER_NAME\n    q = Queue(name=name, connection=Redis(), default_timeout=timeout)\n    return q\n\n\ndef rq_workers(queue=None):\n    # type: (Queue) -> List[Worker]\n    \"\"\"\n    Returns the list of current rq ``Worker``s.\n    \"\"\"\n\n    return Worker.all(connection=Redis(), queue=queue)\n\n\ndef worker_for_job(job_id):\n    # type: (str) -> Optional[Worker]\n    \"\"\"\n    If the job is being run, return its ``Worker``.\n    \"\"\"\n    for worker in rq_workers():\n        # If the worker process no longer exists, skip it. From \"man 2\n        # kill\": \"If sig is 0, then no signal is sent, but existence\n        # and permission checks are still performed; this can be used\n        # to check for the existence of a process ID or process group\n        # ID that the caller is permitted to signal.\"\n        try:\n            os.kill(worker.pid, 0)\n        except OSError:\n            continue\n\n        # If it's running and working on the given job, return it.\n        if worker.state == WorkerStatus.BUSY and job_id == worker.get_current_job_id():\n            return worker\n    return None\n\n\ndef requeue_interrupted_jobs(queue_name=None):\n    # type: (str) -> None\n    \"\"\"\n    Requeues jobs found in the given queue's started job registry.\n\n    Only restarts those that aren't already queued or being run.\n\n    When rq starts a job, it records it in the queue's started job\n    registry. If the server is rebooted before the job completes, the\n    job is not automatically restarted from the information in the\n    registry. For tasks like secure deletion of files, this means that\n    information thought to be deleted is still present in the case of\n    seizure or compromise. We have manage.py tasks to clean such files\n    up, but this utility attempts to reduce the need for manual\n    intervention by automatically resuming interrupted jobs.\n\n    This function is predicated on a risky assumption: that all jobs\n    are idempotent. At time of writing, we use rq for securely\n    deleting submission files and hashing submissions for the ETag\n    header. Both of these can be safely repeated. If we add rq tasks\n    that cannot, this function should be improved to omit those.\n    \"\"\"\n    queue = create_queue(queue_name)\n    started_job_registry = StartedJobRegistry(queue=queue)\n\n    queued_job_ids = queue.get_job_ids()\n    logging.debug(\"queued jobs: {}\".format(queued_job_ids))\n    started_job_ids = started_job_registry.get_job_ids()\n    logging.debug(\"started jobs: {}\".format(started_job_ids))\n    job_ids = [j for j in started_job_ids if j not in queued_job_ids]\n    logging.debug(\"candidate job ids: {}\".format(job_ids))\n\n    if not job_ids:\n        logging.info(\"No interrupted jobs found in started job registry.\")\n\n    for job_id in job_ids:\n        logging.debug(\"Considering job %s\", job_id)\n        try:\n            job = started_job_registry.job_class.fetch(job_id, started_job_registry.connection)\n        except NoSuchJobError as e:\n            logging.error(\n                \"Could not find details for job %s: %s\", job_id, e\n            )\n            continue\n\n        logging.debug(\n            \"Job %s enqueued at %s, started at %s\", job_id, job.enqueued_at, job.started_at\n        )\n\n        worker = worker_for_job(job_id)\n        if worker:\n            logging.info(\n                \"Skipping job %s, which is already being run by worker %s\", job_id, worker.key\n            )\n            continue\n\n        logging.info(\"Requeuing job %s\", job)\n\n        try:\n            started_job_registry.remove(job)\n        except InvalidJobOperation as e:\n            logging.error(\"Could not remove job %s from started job registry: %s\", job, e)\n            continue\n\n        try:\n            queue.enqueue_job(job)\n            logging.debug(\"Job now enqueued at %s, started at %s\", job.enqueued_at, job.started_at)\n        except Exception as e:\n            logging.error(\"Could not requeue job %s: %s\", job, e)\n            continue\n", "path": "securedrop/worker.py"}]}