How to use the scitime._utils.TimeoutError function in scitime

To help you get started, we’ve selected a few scitime examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nathan-toubiana / scitime / scitime / _utils.py View on Github external
def wrapper(*args, **kwargs):
            res = [TimeoutError('artificial timeout error')]

            def new_func():
                try:
                    res[0] = func(*args, **kwargs)
                except Exception as e:
                    res[0] = e
            t = Thread(target=new_func)
            t.daemon = True
            try:
                t.start()
                t.join(seconds_before_timeout)
            except Exception as e:
                raise e
            ret = res[0]
            if isinstance(ret, TimeoutError):
                raise ret
github nathan-toubiana / scitime / scitime / _utils.py View on Github external
        @functools.wraps(func)
        def wrapper(*args, **kwargs):
            res = [TimeoutError('artificial timeout error')]

            def new_func():
                try:
                    res[0] = func(*args, **kwargs)
                except Exception as e:
                    res[0] = e
            t = multiprocessing.Process(target=new_func)
            t.daemon = True
            try:
                t.start()
                t.join(seconds_before_timeout)
            except Exception as e:
                raise e
            ret = res[0]
            if isinstance(ret, BaseException):
                t.terminate()
github nathan-toubiana / scitime / scitime / _utils.py View on Github external
res = [TimeoutError('artificial timeout error')]

            def new_func():
                try:
                    res[0] = func(*args, **kwargs)
                except Exception as e:
                    res[0] = e
            t = Thread(target=new_func)
            t.daemon = True
            try:
                t.start()
                t.join(seconds_before_timeout)
            except Exception as e:
                raise e
            ret = res[0]
            if isinstance(ret, TimeoutError):
                raise ret
            return ret
        return wrapper

scitime

Training time estimator for scikit-learn algorithms

BSD-3-Clause
Latest version published 4 years ago

Package Health Score

51 / 100
Full package analysis