I am thinking of using while exitEvent: try: grab_image (1, 100) #do something with the grabbed image except: pass Please suggest.