TimeOut a function in a class ? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: TimeOut a function in a class ? (/thread-37034.html) |
TimeOut a function in a class ? - Armandito - Apr-25-2022 Hey everyone ! Here is my problem : I have defined a class, where I have defined some functions. In the __init__ of my class I can call some of the defined functions . The problem is that some of these functions can sometimes take a long time to execute. How can I set a timeout in these functions, so that they stop if they take too long? For example : class test: def __init__(self): self.do_actions_1() self.do_actions_2() def do_actions_1(self): "bla bla bla bla bla" def do_actions_2(self): "bla bla bla bla bla" If one of these actions takes too long, how can I stop it? Thank you for your answer! :) RE: TimeOut a function in a class ? - Gribouillis - Apr-25-2022 There are some projects to do that in Pypi, such as timeout-decorator |