signal
Set handlers for asynchronous events
signal
is a module that provides mechanisms to set handlers for asynchronous events.
Example
Using the alarm()
function to limit the time a function can run; This is useful when you want to set a timeout. The following example sets an alarm for 5 seconds to excute a loop. If the loop takes more than 5 seconds, a TimeoutException
is raised.
The following example sets an alarm for 5 seconds to excute func()
. If func()
takes more than 5 seconds, a TimeoutException
is raised and the loop continues.
Last updated