Created
June 21, 2018 09:40
-
-
Save nkenna/472662c4b3a966b451eaa890f335afd0 to your computer and use it in GitHub Desktop.
Creating seperate process for while loop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import multiprocessing | |
def continueScript(): | |
try: | |
while True: | |
sleep(0.3) | |
except KeyboardInterrupt: | |
# stop all servos | |
CServo.stop_servo(pinCServo) | |
fDoorServo.stop_servo(pinFrontDoorServo) | |
GPIO.cleanup() | |
# terminate process on keyboard interrupt | |
scriptProcess.terminate() | |
sleep(1) | |
sys.exit(1) | |
scriptProcess = multiprocessing.Process(target=continueScript, args=()).start() | |
sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment