try moving from sleep to threading.Event().wait()