-
Notifications
You must be signed in to change notification settings - Fork 20
Fix cases where the FTDI driver crashes test scripts preventing the power supply from being shut down #229
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
base: main
Are you sure you want to change the base?
Conversation
…eption`. No script catches it meaning that if the FTDI driver raises an exception while a power supply is live, it will not be turned off.
…rances of BaseException with Exception. Realistically there is no reason to be using BaseException over Exception unless you want to kill the program.
clint-lawrence
left a comment
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.
This is a good move in general and it is probably O.K. to just makes this change as is. However the exception handling in the sequencer is also a mess, and catches BaseException in a few places. Which is probably worse than raising some base exceptions :(
So I wonder if we should also review the sequencer and check all the except statements also?
| @@ -1,32 +1,32 @@ | |||
| class SequenceAbort(BaseException): | |||
| class SequenceAbort(Exception): | |||
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.
Since these are all getting touched, It's probably worth making a top level FixateError and deriving all the more specific errors from that.
|
|
||
|
|
||
| class TestRetryExceeded(BaseException): | ||
| class TestRetryExceeded(Exception): |
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.
Perhaps it grows the scope of this PR too much, but generally python exceptions will be suffixed with Error. We could rename them, keeping an alias for compatibility (but probably not worth the churn)
|
@clint-lawrence I don't think that the sequencer should have the Ideally, Fixate would have a resource manager that uses the |
Perhaps, but the sequencer is still a mess. And I'm fairly sure it catches There is one spot that might be worth checking. In this block, the sequencer catches Fixate/src/fixate/sequencer.py Line 370 in 9f42646
|
|
|
If the FTDI driver raises an exception, it raises a
BaseExceptionwhich is a root exception thatcatch Exception as eWILL NOT catch. This will kill every script if this occurs and the shutdown functions will not be called which has resulted in power supplies being left powered. This does not necessarily fix the power supply being left on but it does give the scripts a fighting chance.The second commit 948f4d5 takes this a step further and removes ALL uses of
BaseExceptionas it offers no advantage overExceptionunless we are trying to kill the script.See Why is it recommended to derive from Exception instead of BaseException class in Python?.