Octoprint-Filament-Reloaded
Octoprint-Filament-Reloaded copied to clipboard
Sleep bug (0 integer instead of seconds float)
Under the code here:
def sensor_callback(self, _):
sleep(self.bounce/1000)
The self.bounce
property returns an integer explicitly and in py2.7 the division will result into 0, which will not sleep at all.
One possible solution would actually be:
def sensor_callback(self, _):
sleep(float(self.bounce) / 1000)
since we use the bounce in ms for the GPIO event (and we pass an integer there).
Also, I find this bug beneficial for the logic, because I don't feel like it should sleep there (therefore a sleep(0) will do nothing, which is the intended behaviour) as the event is already raised every bounce
ms and the callback shouldn't block.
Finally, I think it's best to remove the sleeping entirely.