'How to interrupt function by signal?

I want to code decorator which interrupt function after 1 sec, so:

@timer
def func():
    sleep(0.1)

is OK, but

@timer
def func():
    sleep(1.1)

is RunTimeError.

But i dont understand where in decorator i should code signal. maybe there are similar examples?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source