How to use the colin.utils.cmd_tools.exit_after function in colin

To help you get started, we’ve selected a few colin 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 user-cont / colin / tests / unit / test_utils.py View on Github external
@exit_after(1)
def slow_fce():
    time.sleep(2)
github user-cont / colin / tests / unit / test_utils.py View on Github external
@exit_after(1)
def bad_fce():
    raise ColinException("Error")
github user-cont / colin / tests / unit / test_utils.py View on Github external
def test_timeout_dirrect():
    with pytest.raises(TimeoutError):
        exit_after(1)(time.sleep)(2)
github user-cont / colin / colin / core / check_runner.py View on Github external
def _result_generator(target, checks, timeout=None):
    try:
        for check in checks:
            logger.debug("Checking {}".format(check.name))
            try:
                _timeout = timeout or check.timeout or CHECK_TIMEOUT
                logger.debug("Check timeout: {}".format(_timeout))
                yield exit_after(_timeout)(check.check)(target)
            except TimeoutError as ex:
                logger.warning(
                    "The check hit the timeout: {}".format(_timeout))
                yield FailedCheckResult(check, logs=[str(ex)])
            except Exception as ex:
                tb = traceback.format_exc()
                logger.warning(
                    "There was an error while performing check: {}".format(tb))
                yield FailedCheckResult(check, logs=[str(ex)])
    finally:
        target.clean_up()