What is difference between sys.exit(0) and os._exit(0)

According to the documentation:

os._exit():

Exit the process with status n, without calling cleanup handlers, flushing stdio buffers, etc.

Note The standard way to exit is sys.exit(n). _exit() should normally only be used in the child process after a fork().

Leave a Comment