Timeout for python inputs
Project description
timedinput
A Python module that waits for a specified amount of time for user input. If no input is received within the given timeout period, the module returns a default value or raises an exception.
Unlike standard timeout modules, timedinput actively monitors keystrokes and fully supports modern interactive environments like Jupyter Notebooks, Google Colab, and VS Code.
Installation
Standard installation for standard terminals (Windows/macOS/Linux):
pip install timedinput
For Jupyter/Colab Support: To enable timeout functionality inside Jupyter environments, install the optional UI dependencies:
pip install timedinput[jupyter]
(If you use timedinput in Jupyter without these dependencies, it will gracefully fall back to a standard, non-timing input() prompt to prevent crashes).
Usage
The timedinput function takes three optional arguments: prompt, timeout, and default.
from timedinput import timedinput
# Prompt the user for input with a timeout of 10 seconds
user_input = timedinput("Enter something: ", timeout=10)
# Prompt the user for input with a timeout of 5 seconds and a default value
user_input = timedinput("Enter something: ", timeout=5, default="default")
If the user enters input within the specified timeout, the function returns the user's input as a string. If the user does not enter input within the specified timeout, the function returns the default value (if one was provided) or raises a TimeoutOccurred exception.
Compatibility
- Terminals: Works perfectly on all standard terminals across Windows and Unix-like operating systems.
- Interactive: Fully compatible with JupyterLab, Classic Notebook, Google Colab, and VS Code Interactive windows.
License
Released under the MIT License. See the LICENSE file for more information.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file timedinput-2.0.0.tar.gz.
File metadata
- Download URL: timedinput-2.0.0.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d61eaf08d48266f32bf75645f9b0ce6ea30a76bbdb119aea602875100402b2cc
|
|
| MD5 |
505e008f3f754fa0a3a956c6cc325be0
|
|
| BLAKE2b-256 |
336ae770d376a87dbbf14ee02c2c771c55804a914aef9ebfe35223278fbb0916
|
Provenance
The following attestation bundles were made for timedinput-2.0.0.tar.gz:
Publisher:
python-publish.yml on kerollosy/timedinput
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
timedinput-2.0.0.tar.gz -
Subject digest:
d61eaf08d48266f32bf75645f9b0ce6ea30a76bbdb119aea602875100402b2cc - Sigstore transparency entry: 1549812811
- Sigstore integration time:
-
Permalink:
kerollosy/timedinput@56b1d0d2f274a9d358578d80762d2ec01a02f6c3 -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/kerollosy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@56b1d0d2f274a9d358578d80762d2ec01a02f6c3 -
Trigger Event:
release
-
Statement type:
File details
Details for the file timedinput-2.0.0-py3-none-any.whl.
File metadata
- Download URL: timedinput-2.0.0-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82123979328243a36e0e9d077078d7ec7123ac71ec915ff423daebaac80cf99a
|
|
| MD5 |
acadd173b9c55947215c0f7f40c62734
|
|
| BLAKE2b-256 |
738f043c779d8b57fa5291306b757a89266c567394929c7a4c1ee899a55e4115
|
Provenance
The following attestation bundles were made for timedinput-2.0.0-py3-none-any.whl:
Publisher:
python-publish.yml on kerollosy/timedinput
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
timedinput-2.0.0-py3-none-any.whl -
Subject digest:
82123979328243a36e0e9d077078d7ec7123ac71ec915ff423daebaac80cf99a - Sigstore transparency entry: 1549812834
- Sigstore integration time:
-
Permalink:
kerollosy/timedinput@56b1d0d2f274a9d358578d80762d2ec01a02f6c3 -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/kerollosy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@56b1d0d2f274a9d358578d80762d2ec01a02f6c3 -
Trigger Event:
release
-
Statement type: