Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions src/odemis/util/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,21 +138,23 @@ def stop_backend():
"""
cmd = ODEMISD_CMD + ["--kill"]
ret = subprocess.call(cmd)
if ret != 0:
raise IOError("Failed stopping backend with '%s' (returned %d)" % (cmd, ret))

# wait for the backend to be fully stopped
time.sleep(1) # time to stop
end = time.time() + 15 # s timeout
while time.time() < end:
status = driver.get_backend_status()
if status in (driver.BACKEND_RUNNING, driver.BACKEND_STARTING):
logging.info("Backend is stopping...")
time.sleep(1)
if ret == 0:
status = None
# wait for the backend to be fully stopped
time.sleep(1) # time to stop
end = time.time() + 15 # s timeout
while time.time() < end:
status = driver.get_backend_status()
if status in (driver.BACKEND_RUNNING, driver.BACKEND_STARTING):
logging.info("Backend is stopping...")
time.sleep(1)
else:
break
else:
break
logging.warning("Backend still stopping after 15 s")
else:
logging.warning("Backend still stopping after 15 s")
status = driver.BACKEND_DEAD
logging.warning("Failed stopping backend with '%s' (returned %d)", cmd, ret)
Comment on lines 155 to +157
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On non-zero return from the odemisd --kill command, this sets status = driver.BACKEND_DEAD, which forces the later sudo odemis-stop path even when there is actually no backend running (e.g. odemisd --kill exits non-zero with "No running back-end to kill"). Consider setting status = driver.get_backend_status() (or at least checking for BACKEND_STOPPED) so sudo odemis-stop is only attempted when the backend is still running/unresponsive.

Copilot uses AI. Check for mistakes.
Comment on lines 155 to +157
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new behavior for the ret != 0 branch (falling back to sudo odemis-stop when the polite stop request fails) isn’t covered by a test. Adding a unit test that mocks subprocess.call to return non-zero and asserts the correct fallback behavior (and that it avoids calling sudo when get_backend_status() is already BACKEND_STOPPED) would help prevent regressions.

Copilot generated this review using guidance from repository custom instructions.

model._core._microscope = None # force reset of the microscope for next connection

Expand Down
Loading