-
Notifications
You must be signed in to change notification settings - Fork 26
Added timeout which raises an exception to avoid an infinite loop #35
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
Added timeout which raises an exception to avoid an infinite loop #35
Conversation
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.
Good catch.. I've never run into it having here but I agree taht the timeout is a good idea.
You will have to run 'black' on the code to keep CI happy. It want the single quotes to be double quotes soon the error message text. If ou are not familiar with black, see https://learn.adafruit.com/improve-your-code-with-pylint/black
I have tested the change on a Raspberry Pi zeroW with RFM69 bonnet. No problems.
adafruit_rfm69.py
Outdated
while not self.mode_ready: | ||
pass | ||
if (time.monotonic() - start) >= 1: | ||
raise RuntimeError('Operation mode failed to set.') |
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.
black wants double quotes here...
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.
I'll change to double quotes. Thanks for the link about Black.
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.
@BiffoBear This looks OK to me,
We should discuss the exception type, error message and timeout duration.
What do you mean by this?
I normally write code for my own consumption, so I would like a little feedback regarding |
Updating https://github.com/adafruit/Adafruit_CircuitPython_CharLCD to 3.3.7 from 3.3.6: > Merge pull request adafruit/Adafruit_CircuitPython_CharLCD#57 from BiffoBear/fix-home-docstring Updating https://github.com/adafruit/Adafruit_CircuitPython_DymoScale to 1.1.2 from 1.1.1: > Merge pull request adafruit/Adafruit_CircuitPython_DymoScale#10 from adafruit/REUSE > Added pre-commit-config file Updating https://github.com/adafruit/Adafruit_CircuitPython_EMC2101 to 1.1.3 from 1.1.2: > Merge pull request adafruit/Adafruit_CircuitPython_EMC2101#4 from MaxBec/hotfix_pwm_freq Updating https://github.com/adafruit/Adafruit_CircuitPython_FocalTouch to 1.2.4 from 1.2.3: > Merge pull request adafruit/Adafruit_CircuitPython_FocalTouch#19 from kmatch98/add_irq Updating https://github.com/adafruit/Adafruit_CircuitPython_PyPortal to 5.1.2 from 5.1.1: > Merge pull request adafruit/Adafruit_CircuitPython_PyPortal#105 from jfurcean/fix_api_docs > Merge pull request adafruit/Adafruit_CircuitPython_PyPortal#104 from adafruit/dherrada-patch-1 Updating https://github.com/adafruit/Adafruit_CircuitPython_RFM69 to 2.1.2 from 2.1.1: > Merge pull request adafruit/Adafruit_CircuitPython_RFM69#35 from BiffoBear/add-timeout-to-op-mode_setter Updating https://github.com/adafruit/Adafruit_CircuitPython_PIOASM to 0.1.4 from 0.1.3: > Merge pull request adafruit/Adafruit_CircuitPython_PIOASM#5 from dglaude/patch-1 Updating https://github.com/adafruit/Adafruit_CircuitPython_ProgressBar to 1.3.6 from 1.3.5: > Merge pull request adafruit/Adafruit_CircuitPython_ProgressBar#24 from adafruit/REUSE > Added pre-commit-config file Updating https://github.com/adafruit/Adafruit_CircuitPython_RTTTL to 2.4.4 from 2.4.3: > Merge pull request adafruit/Adafruit_CircuitPython_RTTTL#23 from adafruit/dherrada-patch-1
While instantiating an RFM69 I found that the RFM driver was hanging because
self.mode_ready
was never True. Added a 1 second timeout that raises an exception. We should discuss the exception type, error message and timeout duration.