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.1.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.1-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: timed_prompt-0.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 91981375adaa421384ce92d27baf5bf3fea29fbfe5843a4e64481e2e1f8f8006
MD5 f2e506cb5ae92d09acae0f9825019da2
BLAKE2b-256 4e660ce0ad5ec8fcfc6f6dcc81a072d4435e09c4cefda47e08445f2bad975297

See more details on using hashes here.

File details

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

File metadata

  • Download URL: timed_prompt-0.0.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6fc43b0048c712fbee08ff746c9d01c72ec283c556642f13ee093671c88590a3
MD5 493d1573b6278b28edade11288b87126
BLAKE2b-256 2cc13336828bc90d3a219ef20454328e8ad3f5d31b209f7bf25cbe764fdc95a0

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