skillfed

python-timeout

Random timeout between minimum and maximum values

python-timeout v2026.6.30 144.3K downloads/30d#11,155 on PyPI0
License unclear Active released

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-timeout

uv

uv add python-timeout

poetry

poetry add python-timeout

Installing 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

random timeout generatorsleep with random delaytime-based sleep functiontimeout between min and maxscheduled sleep timer
timing-utilitiestesting-helpers

More Utilities packages