-
Notifications
You must be signed in to change notification settings - Fork 41
[fix] util stop_backend() should always try odemis-stop if nice request fails #3348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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
|
||
|
|
||
| model._core._microscope = None # force reset of the microscope for next connection | ||
|
|
||
|
|
||
There was a problem hiding this comment.
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 --killcommand, this setsstatus = driver.BACKEND_DEAD, which forces the latersudo odemis-stoppath even when there is actually no backend running (e.g.odemisd --killexits non-zero with "No running back-end to kill"). Consider settingstatus = driver.get_backend_status()(or at least checking forBACKEND_STOPPED) sosudo odemis-stopis only attempted when the backend is still running/unresponsive.