From d356cdf6eea7ffac4f10c8a2966c86f490b043cd Mon Sep 17 00:00:00 2001 From: Username Date: Sat, 20 Dec 2025 23:11:54 +0100 Subject: [PATCH] docs: mark priority queue complete --- TODO.md | 46 +++++++++------------------------------------- 1 file changed, 9 insertions(+), 37 deletions(-) diff --git a/TODO.md b/TODO.md index 164e6c9..cdb089b 100644 --- a/TODO.md +++ b/TODO.md @@ -74,44 +74,16 @@ to fetch.py. Updated ppf.py to use these functions instead of local cache. --- -### [ ] 9. Priority Queue for Proxy Testing +### [x] 9. Priority Queue for Proxy Testing -**Problem:** All proxies tested with equal priority. Should prioritize: -- Recently successful proxies (verify still working) -- New proxies (determine if usable) -- Low fail-count proxies - -**Implementation:** -```python -# proxywatchd.py -import heapq - -class PriorityJobQueue: - """Priority queue wrapper for proxy test jobs.""" - def __init__(self): - self.heap = [] - self.lock = threading.Lock() - - def put(self, job, priority): - """Lower priority number = higher priority.""" - with self.lock: - heapq.heappush(self.heap, (priority, id(job), job)) - - def get(self, timeout=None): - """Get highest priority job.""" - # ... implementation with timeout -``` - -Priority calculation: -- New proxy (retrievals=0): priority 0 -- Recent success (last_success < 1hr): priority 1 -- Low fail count (failed < 3): priority 2 -- Medium fail count: priority 3 -- High fail count: priority 4 - -**Files:** proxywatchd.py -**Effort:** Medium -**Risk:** Medium +**Completed.** Added priority-based job scheduling for proxy tests. +- PriorityJobQueue class with heap-based ordering +- calculate_priority() assigns priority 0-4 based on proxy state +- Priority 0: New proxies (never tested) +- Priority 1: Working proxies (no failures) +- Priority 2: Low fail count (< 3) +- Priority 3-4: Medium/high fail count +- Integrated into prepare_jobs() for automatic prioritization ---