Algorithms & Data Structures

Artifact Overview

This enhancement involved implementing an optimized request queue to manage asynchronous media downloads for the HELIOS project. Using Python, I created a `MediaRequestQueue` class that applies fundamental data structure principles to ensure orderly processing, duplication prevention, and efficient memory usage.

Project Background

The HELIOS system receives many automated media requests from integrated services like Sonarr and Radarr. Prior to this enhancement, requests were unstructured and vulnerable to duplication or overflow. To improve the reliability of this system, I implemented a FIFO-style queue with a configurable maximum size and safety checks.

Enhancement Highlights

Preview the Code

Below is a snippet from the custom request queue class:


class MediaRequestQueue:
    def __init__(self, max_size=50):
        self.queue = []
        self.max_size = max_size

    def enqueue(self, request):
        if request not in self.queue and len(self.queue) < self.max_size:
            self.queue.append(request)

    def dequeue(self):
        if self.queue:
            return self.queue.pop(0)
        return None

    def peek(self):
        return self.queue[0] if self.queue else None
      

Download / View Files

Reflection

This enhancement reinforced my understanding of how abstract data structures translate into real-world functionality. Managing asynchronous workflows with a queue helped reduce system errors and laid the foundation for more advanced request processing features in the future.