timeout-sampler
Timeout utility class to wait for any function output and interact with it in given time
Decision gist · record as of 2026-08-14
Yes, if you need polling with selective exception handling and timeout-based retry logic. The active maintenance and permissive license are favorable. However, verify whether pytest is a true runtime dependency—if it is, the high install friction may be a concern for lightweight deployments. The minimal community visibility (0 stars) suggests limited real-world validation, so evaluate it in a test environment first.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python >=3.10
- High install friction due to two runtime dependencies (pytest and python-simple-logger).
- Active maintenance with a recent release (24 days ago), though the project has minimal community visibility (0 stars).
License · maintenance · safety
Apache-2.0 (permissive) — Apache-2.0 permissive license allows commercial and private use with minimal restrictions; suitable for most projects.
last release 2026-07-21 (24 days) · last repo commit 2026-08-13
0 known vulnerabilities (OSV.dev, 2026-08-14) · 184,964 downloads/mo, #10,022 on PyPI
Alternatives
Verify before relying
from timeout_sampler import TimeoutSampler
for sample in TimeoutSampler(
wait_timeout=60,
sleep=1,
func=my_function,
arg1=value1,
):
if sample:
break- Whether pytest is truly required at runtime or only for testing (listed as runtime dependency but typically test-only)
- Performance characteristics when polling high-frequency or long-running functions
- Behavior and overhead of sensitive-key redaction in logging
What it is and what it does
TimeoutSampler is a polling utility that repeatedly calls a function at fixed intervals until it returns a truthy value or a timeout expires. It wraps the function call in a loop, sleeping between attempts, and can be configured to ignore or retry on specific exception types—either all instances of an exception class or only those matching string patterns or callable filters. The package includes a decorator form (@retry) for wrapping functions directly.
The primary use case is waiting for external conditions (SSH connectivity, service availability, async task completion) with fine-grained control over which exceptions should trigger retries versus immediate failure. It logs outcomes (success, failure, timeout) with elapsed time and optional custom labels, and automatically redacts sensitive kwargs like Authorization headers from logs.
Use it for
- Wait for a service to become available before proceeding with integration tests or deployment scripts
- Retry API calls with selective exception handling (e.g., retry on 5xx errors but fail immediately on 4xx)
- Poll for completion of long-running background tasks with a timeout and custom logging
- Decorate functions to add automatic retry logic with timeout and exception filtering
- Wait for SSH or network connectivity with detailed logging of connection attempts
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need polling with selective exception handling and timeout-based retry logic.
The active maintenance and permissive license are favorable. However, verify whether pytest is a true runtime dependency—if it is, the high install friction may be a concern for lightweight deployments. The minimal community visibility (0 stars) suggests limited real-world validation, so evaluate it in a test environment first.
Install
timeout-sampler on PyPI
Before you install
High install friction due to two runtime dependencies (pytest and python-simple-logger). Active maintenance with a recent release (24 days ago), though the project has minimal community visibility (0 stars).
Requires Python >=3.10
License in practice
Apache-2.0 permissive license allows commercial and private use with minimal restrictions; suitable for most projects.
Quickstart
from timeout_sampler import TimeoutSampler
for sample in TimeoutSampler(
wait_timeout=60,
sleep=1,
func=my_function,
arg1=value1,
):
if sample:
break
Verify before relying
- Whether pytest is truly required at runtime or only for testing (listed as runtime dependency but typically test-only)
- Performance characteristics when polling high-frequency or long-running functions
- Behavior and overhead of sensitive-key redaction in logging
Package facts
| License | Apache-2.0 permissive |
| Python support | Supports the current Python release >=3.10 |
| Install friction | High. Source build required |
| Runtime dependencies | 2 packagespytestpython-simple-logger |
| Maintenance | Actively maintained 24 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 184,964 / month, #10,022 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Operating System :: OS IndependentProgramming Language :: Python :: 3 |
Evidence: timeout_sampler-1.1.2.tar.gz
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “retry with timeout”
- timeout-samplerPolls a function repeatedly within a timeout window, collecting…
- polling2Polling2 lets you wait for a function to return a desired condition…
- retry-decoratorProvides a decorator to automatically retry a function when it raises…
Give your agent the search over MCP, or paste the wish link into any chat.
More Testing packages
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
pytest is a testing framework that lets you write test functions using plain assert statements and automatically discovers and runs them, with detailed failure reporting.
virtualenv creates isolated Python environments where packages can be installed independently without affecting the system Python or other projects.
Coverage.py measures which lines of Python code are executed during test runs, reporting coverage percentages and identifying untested code paths.
Install it if you want to measure test completeness or enforce coverage thresholds in your project.
pytest-asyncio is a pytest plugin that enables writing and running async test functions using the asyncio library, allowing developers to await code directly within test cases.
Install it if you write tests for any asyncio-based code.
A pytest plugin that generates test reports in Common Test Report Format (CTRF) as JSON, compatible with pytest-xdist and pytest-playwright for distributed and browser-based testing.
Install it if you need CTRF-formatted test output for CI/CD integration or cross-tool reporting.
See also inputimeout · polling2 · waiter · retry · python-timeout · reretry · redo · func-timeout · retry2 · waiting