In brief
signal exposes operating-system signal handling. Python handlers run in the main thread of the main interpreter, and available signals vary by platform.
Useful to know
signal exposes operating-system signal handling. Python handlers run in the main thread of the main interpreter, and available signals vary by platform. [1]
For shutdown, prefer a small action that activates a defined cleanup path. Do not assume one operating system’s behaviour is universal. A long-running extension operation can affect when Python gets an opportunity to handle the signal.
Sources
For further detail and to check the information: