Gmanc2
Gmanc2

Reputation: 35

Python script complete exit

I'm currently using quit() to end my program but the command line still persists after the execution has finished. How do I "kill" the program?

def ed():
    quit()

timer = threading.Timer(time, ed)
timer.start()

The pointer stays active and acts like the script is running.

Upvotes: 2

Views: 60

Answers (2)

Artyom Vancyan
Artyom Vancyan

Reputation: 5370

You can use standard function of Python exit() which can print whatever before exiting and exit from program.

print("start") 
exit() # exiting from program
print("end") 

start

or

print("start") 
exit("exiting") # exiting with output
print("end") 

start

exiting

Upvotes: 1

sxeros
sxeros

Reputation: 672

This could work:

import os

def ed():
    os._exit(1)

Upvotes: 1

Related Questions