Skip to content

Timeout utility class to wait for any function output and interact with it in given time

Notifications You must be signed in to change notification settings

RedHatQE/timeout-sampler

Repository files navigation

TimeoutSampler

Utility class for waiting to any function output and interact with it in given time.

Installation

pip3 install timeout-sampler

Usage

from random import randint
from timeout_sampler import TimeoutSampler


def random_number(start, end):
    return randint(start, end)


samples = TimeoutSampler(
    wait_timeout=60,
    sleep=1,
    func=random_number,
    start=1,
    end=10,
)
for sample in samples:
    if sample == 5:
        break

About

Timeout utility class to wait for any function output and interact with it in given time

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages