# python-timeout-iterator
`timeout-iterator` provides a timeout in iteration.
[![Python](https://img.shields.io/pypi/pyversions/timeout-iterator.svg)](https://badge.fury.io/py/timeout-iterator)
[![PyPI version](https://img.shields.io/pypi/v/timeout-iterator.svg)](https://pypi.python.org/pypi/timeout-iterator/)
[![codecov](https://codecov.io/gh/kitsuyui/python-timeout-iterator/graph/badge.svg?token=D608CG7CUH)](https://codecov.io/gh/kitsuyui/python-timeout-iterator)
[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
## Installation
```bash
$ pip install timeout-iterator
```
## Usage
### without_terminate
`without_terminate` is a generator that it will not yield after the timeout,
but it will not raise an exception.
```python
from timeout_iterator import without_terminate
results = []
for i in without_terminate(range(10), seconds=0.3):
results.append(i)
time.sleep(0.1)
assert results == [0, 1, 2]
```
### terminate
`terminate` is a generator that it will raise an exception after the timeout.
```python
from timeout_iterator import terminate
try:
results = []
for i in terminate(range(10), seconds=0.3):
results.append(i)
time.sleep(0.1)
except TimeoutError:
pass
assert results == [0, 1, 2]
```
# LICENSE
BSD 3-Clause License
Raw data
{
"_id": null,
"home_page": "https://github.com/kitsuyui/python-timeout-iterator",
"name": "timeout-iterator",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "",
"author": "Yui Kitsu",
"author_email": "kitsuyui+github@kitsuyui.com",
"download_url": "https://files.pythonhosted.org/packages/ce/f2/bd690a81627e0ffd1456a01b329bf468e2387a62ff841fc3b4c92bf2d57f/timeout-iterator-0.1.1.tar.gz",
"platform": null,
"description": "# python-timeout-iterator\n\n`timeout-iterator` provides a timeout in iteration.\n\n[![Python](https://img.shields.io/pypi/pyversions/timeout-iterator.svg)](https://badge.fury.io/py/timeout-iterator)\n[![PyPI version](https://img.shields.io/pypi/v/timeout-iterator.svg)](https://pypi.python.org/pypi/timeout-iterator/)\n[![codecov](https://codecov.io/gh/kitsuyui/python-timeout-iterator/graph/badge.svg?token=D608CG7CUH)](https://codecov.io/gh/kitsuyui/python-timeout-iterator)\n[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)\n\n## Installation\n\n```bash\n$ pip install timeout-iterator\n```\n\n## Usage\n\n### without_terminate\n\n`without_terminate` is a generator that it will not yield after the timeout,\nbut it will not raise an exception.\n\n```python\nfrom timeout_iterator import without_terminate\nresults = []\nfor i in without_terminate(range(10), seconds=0.3):\n results.append(i)\n time.sleep(0.1)\n\nassert results == [0, 1, 2]\n```\n\n### terminate\n\n`terminate` is a generator that it will raise an exception after the timeout.\n\n```python\nfrom timeout_iterator import terminate\ntry:\n results = []\n for i in terminate(range(10), seconds=0.3):\n results.append(i)\n time.sleep(0.1)\nexcept TimeoutError:\n pass\n\nassert results == [0, 1, 2]\n```\n\n# LICENSE\n\nBSD 3-Clause License\n",
"bugtrack_url": null,
"license": "BSD-3-Clause",
"summary": "Iterator with timeout",
"version": "0.1.1",
"project_urls": {
"Homepage": "https://github.com/kitsuyui/python-timeout-iterator"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e350eda0322477196c8b0d54ef74e7365ea70bc8d2283bc5aa4e2072ae1096ac",
"md5": "f355821d6327dbe5b67e6299e88ad214",
"sha256": "a84a7cfc9271a396f8c9c74b8da8a7b7dab246af23c879d5484391a05a1acf0b"
},
"downloads": -1,
"filename": "timeout_iterator-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f355821d6327dbe5b67e6299e88ad214",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 3562,
"upload_time": "2024-01-11T09:47:21",
"upload_time_iso_8601": "2024-01-11T09:47:21.443253Z",
"url": "https://files.pythonhosted.org/packages/e3/50/eda0322477196c8b0d54ef74e7365ea70bc8d2283bc5aa4e2072ae1096ac/timeout_iterator-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "cef2bd690a81627e0ffd1456a01b329bf468e2387a62ff841fc3b4c92bf2d57f",
"md5": "66d8e1d15ab14d93e5ddf2454916a0c3",
"sha256": "66748eb5bfcbe665c07c6e18604da589055432b07e975663e0b6bda7c669eb13"
},
"downloads": -1,
"filename": "timeout-iterator-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "66d8e1d15ab14d93e5ddf2454916a0c3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 15861,
"upload_time": "2024-01-11T09:47:22",
"upload_time_iso_8601": "2024-01-11T09:47:22.852524Z",
"url": "https://files.pythonhosted.org/packages/ce/f2/bd690a81627e0ffd1456a01b329bf468e2387a62ff841fc3b4c92bf2d57f/timeout-iterator-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-11 09:47:22",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "kitsuyui",
"github_project": "python-timeout-iterator",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "timeout-iterator"
}