Skip to content

bug fixes which i found step by steps #1792

@earnadvise

Description

@earnadvise

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions