Speeding up Python's exit

Grant Edwards invalid at invalid.invalid
Thu Feb 28 20:17:12 EST 2013


On 2013-02-28, Steven D'Aprano <steve+comp.lang.python at pearwood.info> wrote:

> I know there is a function os._exit which effectively kills the
> Python interpreter dead immediately, without doing any cleanup. What
> are the consequences of doing this?

You loose any data you haven't saved to disk.

> I assume that the memory used by the Python process will be reclaimed
> by the operating system, but other resources such as opened files may
> not be.

All open files (including sockets, pipes, serial ports, etc) will be
flushed (from an OS standpoint) and closed.  If you've closed all the
files you've written to, there should be no danger in just pulling the
plug.

-- 
Grant




More information about the Python-list mailing list