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

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/
│   ├── __init__.py
│   └── prompt.py
├── README.md
├── pyproject.toml
├── LICENSE
├── MANIFEST.in
├── .gitignore
└── examples/
    └── demo.py

📦 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.2.tar.gz (4.7 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.2-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: timed_prompt-0.0.2.tar.gz
  • Upload date:
  • Size: 4.7 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.2.tar.gz
Algorithm Hash digest
SHA256 a9d2bc10beaa9378bf160ff452aa65d6d55f147b215021705d445db8037f0022
MD5 ea063ad4fd688ec9294adb91c1870137
BLAKE2b-256 52f8e3089098f7a36770ff339c11239c20cc63aa8f14f1b7cfcb288562f0e169

See more details on using hashes here.

File details

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

File metadata

  • Download URL: timed_prompt-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.8 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 dd8619320e3c76e75f8a95c10f20fe6a6b3183d962701f1111ecb01ca8d97c5b
MD5 c6efbb7e84b78f2bd3bb7c5bd090c2d6
BLAKE2b-256 12bbb87b5ae87169001b2b28c233fad31da90faaf7ffbbe747700e8bf83fd078

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