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 (
) is:
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 before get_request(). The result of io.recieve_time() is then being passed into get_request() as the value for ping, which as shown above simply copies that value into n, which it then returns as the result of get_request(). So io.recieve_time() is being invoked outside of the retry code in get_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 of ping, which with the change I suggest above, will then be invoked inside the retry loop in get_request.
(Edit: formatting typo)
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 = pingThis 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)