How to Stop python programme (which is continuously giving output ) after sometime
Dineshchitta
0
Newbie Poster
Recommended Answers
Jump to Postwill exit your program after 5 seconds
This fails, but using
os._exit(0)
works, instead ofsys.exit(0)
.In my linux system, the following also works, which is very nice
import thread import threading threading.Timer(2.0, lambda : thread.interrupt_main()).start() try: while True: print("stopme") except KeyboardInterrupt: print("We're …
All 2 Replies
CrazyDieter
4
Junior Poster
Gribouillis
1,391
Programming Explorer
Team Colleague
CrazyDieter
commented:
you're right, I prefer this way too
+3
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.