Python freeze function

I am sure this has been asked before, but I cannot find a similar example. I need to be able to call a function with a temporary runtime. If the function takes this time, then the script completes.

This cannot be done by selecting the whole script! And I want one, little function to be timed. Is it possible?

for instance

def sleep(): time.sleep(60) time("sleep()", limit=30, violation="sys.exit(1)") 

A very simple and terrible example that I know, but that might help the explanation.

+1
source share
2 answers

I did the same a while ago, following this link here. There is all you need, if I find my code, I will send it to you!

+3
source

Source: https://habr.com/ru/post/906151/


All Articles