Commit ba44b02c authored by Valentin Valls's avatar Valentin Valls
Browse files

Handle PreparedScanEvent as 'on_scan_started'

parent 65fee165
......@@ -115,6 +115,16 @@ class ScansObserver:
"""
pass
def on_scan_started(self, scan_db_name: str, scan_info: Dict):
"""
Called upon scan started (the devices was prepared).
Arguments:
scan_db_name: Identifier of the scan
scan_info: Dictionary containing scan metadata
"""
pass
def on_child_created(self, scan_db_name: str, node):
"""
Called upon scan child creation (e.g. channel node)
......@@ -403,6 +413,16 @@ class ScansWatcher:
)
except Exception:
sys.excepthook(*sys.exc_info())
elif event_type == EventType.PREPARED_SCAN:
node_type = node.type
if self._watch_scan_group or node_type == "scan":
db_name = node.db_name
if db_name in self._running_scans:
scan_info = node.info.get_all()
try:
observer.on_scan_started(db_name, scan_info)
except Exception:
sys.excepthook(*sys.exc_info())
elif event_type == EventType.END_SCAN:
node_type = node.type
if self._watch_scan_group or node_type == "scan":
......
......@@ -466,7 +466,9 @@ def test_scan_observer(session, diode_acq_device_factory, mocker):
gevent.sleep(0.5)
session_watcher.kill()
# TODO check the order of the received events
observer.on_scan_created.assert_called_once()
observer.on_scan_started.assert_called_once()
observer.on_scan_finished.assert_called_once()
call = observer.on_scan_created.call_args_list[0]
scan_info = call[0][1]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment