data problem fix
This commit is contained in:
@@ -86,7 +86,9 @@ class AppWindowPipelineMixin:
|
||||
self._single_capture_seen_raw = False
|
||||
self._single_capture_target_collection_id = None
|
||||
|
||||
self._drop_pending_ring_payloads(include_results=not single_capture)
|
||||
# Always drop unread payloads for all stages so single-capture starts
|
||||
# from a clean boundary and does not retain stale results-only tail.
|
||||
self._drop_pending_ring_payloads(include_results=True)
|
||||
if single_capture:
|
||||
self._single_capture_start_ns = time.monotonic_ns()
|
||||
|
||||
@@ -208,7 +210,7 @@ class AppWindowPipelineMixin:
|
||||
self._update_history_indicator()
|
||||
|
||||
if self._single_capture_active:
|
||||
if self._finish_single_capture_if_ready(result_latest):
|
||||
if self._finish_single_capture_if_ready():
|
||||
return
|
||||
return
|
||||
|
||||
@@ -216,31 +218,41 @@ class AppWindowPipelineMixin:
|
||||
except Exception as exc: # noqa: BLE001
|
||||
self._log(f"Reader error: {exc}")
|
||||
|
||||
def _finish_single_capture_if_ready(self, result_latest: ResultCollection | None) -> bool:
|
||||
"""Finalize single capture when new result matching start criteria is available."""
|
||||
def _finish_single_capture_if_ready(self) -> bool:
|
||||
"""Finalize single capture when the exact target result becomes available."""
|
||||
if not self._single_capture_active:
|
||||
return False
|
||||
if result_latest is None:
|
||||
return False
|
||||
if self._single_capture_start_ns is None:
|
||||
return False
|
||||
if not self._single_capture_seen_raw:
|
||||
return False
|
||||
if (
|
||||
self._single_capture_target_collection_id is not None
|
||||
and result_latest.collection_id < self._single_capture_target_collection_id
|
||||
):
|
||||
return False
|
||||
if result_latest.monotonic_ns < self._single_capture_start_ns:
|
||||
return False
|
||||
if not self._result_collection_has_trace(result_latest):
|
||||
target_result = self._find_single_capture_target_result()
|
||||
if target_result is None:
|
||||
return False
|
||||
|
||||
self._draw_results(result_latest)
|
||||
self._draw_results(target_result)
|
||||
self._log("Single capture completed")
|
||||
self._stop_run()
|
||||
return True
|
||||
|
||||
def _find_single_capture_target_result(self) -> ResultCollection | None:
|
||||
"""Return the exact result collection corresponding to the captured target raw sweep."""
|
||||
if self._single_capture_target_collection_id is None:
|
||||
return None
|
||||
if self._single_capture_start_ns is None:
|
||||
return None
|
||||
|
||||
for collection in reversed(self._result_history):
|
||||
if collection.collection_id != self._single_capture_target_collection_id:
|
||||
continue
|
||||
if collection.monotonic_ns < self._single_capture_start_ns:
|
||||
continue
|
||||
if not self._result_collection_has_trace(collection):
|
||||
continue
|
||||
return collection
|
||||
|
||||
return None
|
||||
|
||||
def _read_all_raw(self) -> SweepCollection | None:
|
||||
"""Read available raw collections from raw ring."""
|
||||
assert self._raw_reader is not None
|
||||
@@ -277,14 +289,10 @@ class AppWindowPipelineMixin:
|
||||
collection = self._result_reader.pop_result_collection()
|
||||
if collection is None:
|
||||
break
|
||||
if self._record_result_history(collection):
|
||||
if record_result_history(self._result_history, collection):
|
||||
latest = collection
|
||||
return latest
|
||||
|
||||
def _record_result_history(self, collection: ResultCollection) -> bool:
|
||||
"""Merge collection into result history preserving de-dup semantics."""
|
||||
return record_result_history(self._result_history, collection)
|
||||
|
||||
def _drain_rings_once_for_history(self) -> None:
|
||||
"""Perform one non-blocking read pass to extend histories."""
|
||||
if self._raw_reader is not None:
|
||||
|
||||
Reference in New Issue
Block a user