Skip to content

Commit

Permalink
No need to initialize Django in another process
Browse files Browse the repository at this point in the history
  • Loading branch information
medihack committed Nov 16, 2023
1 parent 8f5a56d commit 740fff1
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions adit/core/workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from threading import Event
from typing import cast

import django
import humanize
import redis
from django import db
Expand Down Expand Up @@ -116,15 +115,12 @@ def fetch_queued_task(self) -> QueuedTask | None:
queued_task.locked = True
queued_task.save()

logger.debug(f"Next queued task being processed: {queued_task}")
return queued_task
logger.debug(f"Next queued task being processed: {queued_task}")
return queued_task

# Pebble allows us to set a timeout and terminates the process if it takes too long
@concurrent.process(timeout=PROCESS_TIMEOUT, daemon=True)
def process_dicom_task(self, queued_task_id: int) -> None:
# As we run this in a separate process we have to initialize Django
django.setup()

queued_task = QueuedTask.objects.get(id=queued_task_id)
dicom_task = cast(DicomTask, queued_task.content_object)
processor = self._get_processor(dicom_task)
Expand Down

0 comments on commit 740fff1

Please sign in to comment.