-
Notifications
You must be signed in to change notification settings - Fork 770
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
bug in retry code for Star Fragment Lamp #2444
Comments
hello- "ping" is the name of the variable here (but perhaps i should change it to avoid confusion). in the function, the request is passed inside the i did test your suggested fix and it errors out with |
The line where You're seeing the With the proposed change to I didn't realize this line was present until I submitted my pull request, which is why I didn't mention it in the bug report. The lambda expression lets you delay the invocation of This kind of thing is hard to test because it would require causing |
This might help for anyone who needs a refresher for passing functions as parameters/ variables in python. |
I believe there is a bug in the retry code used
get_request()
in the Star Fragment Lamp code.The retry code at line 65 (
Adafruit_Learning_System_Guides/Star_Fragment_Lamp/code.py
Line 65 in a2a2916
n = ping
This simply assigns the value of ping to the variable n. It does not invoke ping. It should be:
n = ping()
The reason the code appears to work is that the retry code is called like this (on line 78 and at least one other location):
now = get_request(5, io.receive_time())
Specifically,
io.recieve_time()
is being invoked beforeget_request()
. The result ofio.recieve_time()
is then being passed intoget_request()
as the value forping
, which as shown above simply copies that value inton
, which it then returns as the result ofget_request()
. Soio.recieve_time()
is being invoked outside of the retry code inget_request()
, which mean it doesn't benefit from any retries. Instead,get_request()
should be invoked like this:now = get_request(5, io.receive_time)
This passes a reference to the
io.recieve_time()
as the value ofping
, which with the change I suggest above, will then be invoked inside the retry loop inget_request
.(Edit: formatting typo)
The text was updated successfully, but these errors were encountered: