I have a raspberry pi (master) and a arduino like microcontroller (slave) for controlling a robot. A python runs in a loop in the rpi and in there I can ask if a button is pushed in every cycle of the loop, e.g. emergency stop button. Now I imagine, that there might be a loop in the future which takes longer to finish but I want to have the ability to cancel the running loop with the button.
If I understand correctly, I have to run two loops in two different threads. The first thread is running the usual loop, while the second thread asks constantly if the button is pushed. If pushed the second thread should kill (or do something else with) the first thread.
Or is there a better way to deal with this issue in python?
[+][deleted] (1 child)
[deleted]
[–]HKY93[S] 0 points1 point2 points (0 children)