Skip to main content

timed-prompt

GitHub Repo GitHub License GitHub Forks GitHub Stars GitHub Contributors

Build Status codecov PyPI Version Test PyPI Version


A cross-platform Python library for input() / getpass() prompts with a real timeout, compatible with Windows, Linux, and macOS.

Unlike the standard input(), this library ensures:

  • Timeout is enforced safely
  • No daemon threads or signals required
  • Works reliably on Windows console
  • Simple SSH-style password prompt UX

✨ Features

  • ✔ Cross-platform: Windows / Linux / macOS
  • ✔ Works with both input() and getpass()
  • ✔ Enforces timeout without hanging or crashing
  • ✔ Optional quiet mode (no prompt output)
  • ✔ Can be used in CLI tools, scripts, and SSH-style workflows

🔹 Project layout

timed-prompt/
├── timed_prompt/          # Importable package
│   ├── __init__.py        # Exposes API
│   └── prompt.py          # Core logic
├── examples/              # Non-package demo scripts
│   └── demo.py
├── .github/
│   └── workflows/
│       └── python-app.yml # CI + Codecov
├── README.md              # PyPI description
├── pyproject.toml         # PEP 621 config
├── LICENSE                # Required for PyPI
├── MANIFEST.in            # Source dist inclusion
└── .gitignore

📦 Installation

pip install timed-prompt

2️⃣ Clone the repository (optional / development)

git clone https://github.com/kumarmuthu/timed-prompt
cd timed-prompt

▶️ Usage

Normal mode (prompt displayed)

from timed_prompt import timed_input_or_getpass

# Prompt displayed normally, 30s timeout
pw = timed_input_or_getpass("Password (30s timeout): ", 30)

if pw is None:
    print("Timed out")
else:
    print(f"Password entered (length): {len(pw)}")

⚠️ Security note: Avoid printing actual passwords in production.

Quiet mode (prompt not printed)

from timed_prompt import timed_input_or_getpass

# Quiet mode: prompt not shown, useful for automated scripts
pw = timed_input_or_getpass("Enter password: ", 20, quiet=True)

if pw is None:
    print("Timed out (quiet mode)")
else:
    print(f"Password entered (quiet mode, length): {len(pw)}")

📁 Example script

python examples/demo.py

Or via CLI entry point after installation:

timed-prompt-demo

Author

Created and maintained by kumarmuthu.


📝 License

MIT License Feel free to use, modify, and contribute.


Metadata

Release files for timed-prompt 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for timed-prompt 0.0.3
File Size Uploaded Provenance
timed_prompt-0.0.3.tar.gz 4.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for timed-prompt 0.0.3
File Interpreter ABI Platform
timed_prompt-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 9.9 kB

Release files / timed_prompt-0.0.3.tar.gz

Download URL timed_prompt-0.0.3.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
bcd5edece3e1a322c2e9c97f85c1dbd6a5da51d9a09513acd94619126065e95a
BLAKE2b-256 checksum
How to use checksums
56d3ed6142f7d2240b3d3db5ec4331b3e5f6ee318d8a252706633a5eb2c52e22
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.5

Release files / timed_prompt-0.0.3-py3-none-any.whl

Download URL timed_prompt-0.0.3-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0c6dacf25eb6eb9983f8033cf7f4e39c95cd246d6a03dbf7f44c75f53a259468
BLAKE2b-256 checksum
How to use checksums
c03ee471b8deebb3b3f1cf7016b3eb45d4190fc3c5f40542f07e1649b70b6639
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.5

Security for timed-prompt 0.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page