phase 2: code cleanup and simplification
- Remove unused result_queue from WorkerThread and worker mode - Remove num_targets abstraction, simplify to single-target mode - Add _db_context() context manager for database connections - Refactor 5 call sites to use context manager (finish, init, cleanup_stale, periodic saves) - Mark _prep_db/_close_db as deprecated - Add __version__ = '2.0.0' to ppf.py - Add thread spawn stagger (0-100ms) in worker mode for Tor-friendly startup
This commit is contained in:
5
ppf.py
5
ppf.py
@@ -1,5 +1,7 @@
|
||||
#!/usr/bin/env python2
|
||||
|
||||
__version__ = '2.0.0'
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
@@ -481,13 +483,12 @@ def worker_main(config):
|
||||
|
||||
# Create shared queues for worker threads
|
||||
job_queue = proxywatchd.PriorityJobQueue()
|
||||
result_queue = Queue.Queue()
|
||||
completion_queue = Queue.Queue()
|
||||
|
||||
# Spawn worker threads with stagger to avoid overwhelming Tor
|
||||
threads = []
|
||||
for i in range(num_threads):
|
||||
wt = proxywatchd.WorkerThread('w%d' % i, job_queue, result_queue)
|
||||
wt = proxywatchd.WorkerThread('w%d' % i, job_queue)
|
||||
wt.start_thread()
|
||||
threads.append(wt)
|
||||
time.sleep(random.random() / 10) # 0-100ms stagger per thread
|
||||
|
||||
Reference in New Issue
Block a user