2

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.

1
  • exit from current situation? Try sending SIGINT to process using Ctrl + C Commented Feb 25, 2020 at 7:38

2 Answers 2

1

This could work:

import os

def ed():
    os._exit(1)
Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.