queueueueue

This commit is contained in:
Lily Miller
2025-10-09 16:44:48 -06:00
parent 782dce4b2d
commit b96a2bb703
3 changed files with 39 additions and 0 deletions

View File

@@ -102,6 +102,28 @@ class OllamaQueue:
return i + 1
return 0
def has_pending_with_priority(self, priority: Priority) -> bool:
"""Check if there are any pending or processing requests with the given priority"""
# Check pending requests
for req_file in self.pending_dir.glob("*.json"):
try:
data = json.loads(req_file.read_text())
if data.get("priority") == priority.value:
return True
except:
pass
# Check processing requests
for req_file in self.processing_dir.glob("*.json"):
try:
data = json.loads(req_file.read_text())
if data.get("priority") == priority.value:
return True
except:
pass
return False
def wait_for_result(
self,
request_id: str,