


> What Can You Learn From This Article? ¶Īs a part of this tutorial, we'll explain how to use Python module "signal" to send, receive and handle UNIX/Windows system signals with simple and easy-to-understand examples. The underlying C code which generally handles this kind of system call will set a flag that will indicate a Python interpreter to execute the handler (callback) function later on. The callback that we register using signal module will be executed by the main thread of the process. The signal module lets us register a callback that will be executed when a signal of a particular type is received, raise a signal, raise signal repeatedly at a specified interval, wait for the signal, send a signal to the thread by id, send a signal to the process by id, etc. Python provides us with a module named signal which lets us perform an operation of our own when any signal is received. > What Solution Python Offers for Working with System Signals? ¶

These kinds of signals are generally handled by the underlying C code. The signal can be of any kind like kill process, terminate the process, interrupt the process, broken pipe, segmentation-fault, window resize, floating point exception, etc. But the main purpose of signal was to make thread or process aware of an event. The execution can be immediate or even a little later. The process or thread can then execute some callback/handler according to event. Many times developers need to send signals of some kind to an ongoing process or threads to inform them about the happening of some kings of event. Signal - Simple Guide to Send, Receive and Handle System Signals in Python ¶ > Why Use System Signals (Unix/Windows)? ¶
