def updateLocThread(): global IS_BUS_START while True: if IS_BUS_START == True: Location.moveOneStop() LOGGER.info("Update Location") sleep(10) # take 10 seconds to move to next stop # if Location reaches the end - 29, turn off if Location.getLocation() == 29: os._exit(0)