-
Notifications
You must be signed in to change notification settings - Fork 943
Open
Description
The fix is to protect all shared variables with a lock so reads and writes happen atomically
Found issues in src/backgrounds/rf_mapper.py that need to be addressed .
import threading
import logging
def init(self):
self.scan_lock = threading.Lock()
self.scan_idx = 0
self.scan_last_sent = 0
self.scan_results = []
self.running = True
2:
def _scan_task(self):
while self.running:
results = self.loop.run_until_complete(self.scan())
with self.scan_lock:
self.scan_results = results
logging.info(f"RF scan index: {self.scan_idx}")
self.scan_idx += 1
3:
def run(self):
while self.running:
with self.scan_lock:
if self.scan_results and self.scan_idx > self.scan_last_sent:
fresh_scan_results = self.scan_results
self.scan_last_sent = self.scan_idx
self.scan_results = []
if fresh_scan_results:
self.process_scan_results(fresh_scan_results)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels