python - how to make timer for quiting from python3 -


i have script , doesn't work proper, in bash let script in while loop , wanna script can close after while, tried use threading.timer code wont run quit() or exit() command, please me?

#!/usr/bin/env python3 import threading time import sleep  def qu():   print("bye")   exit()  t=threading.timer(5.0,qu) t.start()  while(true):   sleep(1)   print("hi") 

you use os._exit function instead of exit()

getting code follows:

#!/usr/bin/env python3 import threading import os time import sleep  def qu():     print("bye")     os._exit(0)  t=threading.timer(5.0,qu) t.start()  while(true):     sleep(1)     print("hi") 

anyways suggest checkout this question similar yours.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -