Skip to content

Instantly share code, notes, and snippets.

@nkenna
Created June 21, 2018 09:40
Show Gist options
  • Save nkenna/472662c4b3a966b451eaa890f335afd0 to your computer and use it in GitHub Desktop.
Save nkenna/472662c4b3a966b451eaa890f335afd0 to your computer and use it in GitHub Desktop.
Creating seperate process for while loop
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