python-timeout
Random timeout between minimum and maximum values
What it is and what it does
python-timeout provides utilities for generating random delays and time-aware sleep operations. It offers two main features: random_timeout() generates a random duration between specified bounds (in seconds, minutes, hours, or days), and sleep() pauses execution for a given duration with similar time-unit flexibility. Additionally, SleepTimer allows you to define active time windows and check whether the current time falls within them.
The package has no runtime dependencies, making it lightweight to install. However, it ships only as a source distribution, which means your system must be able to build it during installation. The license is undeclared, and Python version support is unspecified, creating uncertainty about compatibility and legal terms.
Use it for:
- Implement exponential backoff with randomization in retry logic for network requests or API calls.
- Add jitter to scheduled tasks to avoid thundering-herd problems when many processes wake simultaneously.
- Build time-gated features that only run during specific hours (e.g., maintenance windows or business hours).
- Test timeout and delay behavior in unit tests without hardcoding fixed sleep durations.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Generates random timeouts between specified minimum and maximum values, and provides time-aware sleep functions with optional active-time windows.
Yes, with conditions. The package is lightweight and actively maintained, but the high install friction (source-only distribution), undeclared license, and unspecified Python version support create friction. Install only if you need random timeout generation and can verify the license and Python compatibility in the repository. For simple use cases, consider whether implementing random.uniform() directly meets your needs.
Install
python-timeout on PyPI
pip
pip install python-timeoutuv
uv add python-timeoutpoetry
poetry add python-timeoutInstalling python-timeout
Before you install
High install friction: the package is distributed as a source tarball with no pre-built wheels, requiring compilation or setup.py execution on install. Maintenance is active with a recent release 45 days ago, but the repository has zero stars and no documented Python version requirements.
License in practice
License status is unclear—no SPDX identifier or raw license text is declared. Users should verify the actual license terms in the repository before adopting this package for production use.
Quickstart
pip install python-timeout
from timeout import random_timeout, sleep
random_timeout(10, 20) # Random timeout between 10 and 20 seconds
sleep(5) # Sleep for five seconds
No Python version requirement is specified in the package metadata; verify compatibility with your target Python version before use.
Verify before relying
- Whether the package supports modern Python versions (3.8+) is not documented in the metadata.
- The actual license under which the package is distributed is not declared in PyPI metadata.
- Whether random_timeout blocks execution or returns a value is not clear from the description excerpt.
Package facts
| License | not declared (unclear) |
| Python support | not specified |
| Install friction | high — source build required |
| Runtime dependencies | none |
| Maintenance | actively maintained — 45 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 144,325/month — #11,155 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: python_timeout-2026.6.30.tar.gz
Tags
More Utilities packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
charset-normalizerDetects and normalizes text encoding from…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
retryProvides a decorator and function wrapper for…
permissive · top 1,000 on PyPI
asyncsleepiqAsyncSleepIQ provides async Python access to…
permissive · top 15,000 on PyPI
timeout-samplerPolls a function repeatedly within a timeout…
permissive · top 15,000 on PyPI
win-precise-timeProvides high-resolution time measurement and…
permissive · top 15,000 on PyPI
random-password-generatorGenerates random passwords with configurable…
permissive · top 15,000 on PyPI
pytimeparseParses human-readable time expressions (like…
permissive · top 1,000 on PyPI
monotonicProvides a monotonic clock function that…
permissive · top 5,000 on PyPI
pytest-loopA pytest plugin that repeats tests a fixed…
copyleft · top 15,000 on PyPI
eth-retryA decorator that automatically retries…
permissive · top 15,000 on PyPI
retry2Provides a decorator and function wrapper to…
permissive · top 5,000 on PyPI