Did I find the right examples for you? yes no

All Samples(2)  |  Call(1)  |  Derive(0)  |  Import(1)
Call `func` but terminate after `t` seconds.

        def with_timeout(t, func, *args, **kwargs):
    """Call `func` but terminate after `t` seconds."""
    def timeout_handler(signum, frame):
        raise nagiosplugin.Timeout('{0}s'.format(t))

    signal.signal(signal.SIGALRM, timeout_handler)
    signal.alarm(t)
    try:
        func(*args, **kwargs)
    finally:
        signal.alarm(0)
        


src/n/a/nagiosplugin-1.2.1/src/nagiosplugin/runtime.py   nagiosplugin(Download)
from .output import Output
from .error import Timeout
from .platform import with_timeout
import io
import logging
            self.timeout = int(timeout)
        if self.timeout:
            with_timeout(self.timeout, self.run, check)
        else:
            self.run(check)