Search code examples
pythonpython-3.xpython-multiprocessing

What is the difference between Process.terminate() and Process.kill() in Python multiprocessing?


What is the difference between Process.terminate() and Process.kill() in Python multiprocessing?


Solution

  • terminate() sends the SIGTERM signal to the process

    terminate():
        Terminate the process. On Unix this is done using the SIGTERM signal; on Windows TerminateProcess() is used. Note that exit handlers and finally clauses, etc., will not be executed.
    

    kill() sends the SIGKILL signal to the process.

    kill():
    Same as terminate() but using the SIGKILL signal on Unix.
    

    How the process handles these signals is up to it. Usually, SIGTERM is graceful shutdown while SIGKILL is more of an abort. More details