[Python-Dev] why multiprocessing use os._exit

Tao Qingyun qingyun.tao at tophant.com
Thu Mar 2 23:51:59 EST 2017


in multiprocessing/forking.py#129, `os._exit` cause child process don't close open
file. For example:

```
    from multiprocessing import Process

    def f():
        global log  # prevent gc close the file
        log = open("info.log", "w")
        log.write("***hello world***\n")

    p = Process(target=f)
    p.start()
    p.join()

```
and the `info.log` will be empty. why not use sys.exit ? 


Thanks




More information about the Python-Dev mailing list