Skip to main content

Cross-platform input/getpass prompt with real timeout (Windows/Linux/macOS)

Project description

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

1️⃣ Install via PyPI (recommended)

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.


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

timed_prompt-0.0.3.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

timed_prompt-0.0.3-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file timed_prompt-0.0.3.tar.gz.

File metadata

  • Download URL: timed_prompt-0.0.3.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.5

File hashes

Hashes for timed_prompt-0.0.3.tar.gz
Algorithm Hash digest
SHA256 bcd5edece3e1a322c2e9c97f85c1dbd6a5da51d9a09513acd94619126065e95a
MD5 3b498e2ea97e46747e6b930651d5c589
BLAKE2b-256 56d3ed6142f7d2240b3d3db5ec4331b3e5f6ee318d8a252706633a5eb2c52e22

See more details on using hashes here.

File details

Details for the file timed_prompt-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: timed_prompt-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.5

File hashes

Hashes for timed_prompt-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0c6dacf25eb6eb9983f8033cf7f4e39c95cd246d6a03dbf7f44c75f53a259468
MD5 fe78eecc6c932fae84bbd1737b7f3e2d
BLAKE2b-256 c03ee471b8deebb3b3f1cf7016b3eb45d4190fc3c5f40542f07e1649b70b6639

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page