timeout-iterator 0.1.1__tar.gz → 0.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. {timeout-iterator-0.1.1 → timeout_iterator-0.2.1}/.github/workflows/gitignore-in.yml +1 -1
  2. {timeout-iterator-0.1.1 → timeout_iterator-0.2.1}/.github/workflows/pypi-publish.yml +8 -16
  3. {timeout-iterator-0.1.1 → timeout_iterator-0.2.1}/.github/workflows/python-test.yml +17 -22
  4. timeout_iterator-0.2.1/LICENSE +11 -0
  5. {timeout-iterator-0.1.1 → timeout_iterator-0.2.1}/PKG-INFO +18 -8
  6. timeout_iterator-0.2.1/pyproject.toml +65 -0
  7. timeout_iterator-0.2.1/setup.cfg +4 -0
  8. {timeout-iterator-0.1.1 → timeout_iterator-0.2.1}/tests/test_terminate.py +23 -0
  9. {timeout-iterator-0.1.1 → timeout_iterator-0.2.1}/timeout_iterator/_version.py +2 -2
  10. {timeout-iterator-0.1.1 → timeout_iterator-0.2.1}/timeout_iterator/terminate.py +5 -2
  11. {timeout-iterator-0.1.1 → timeout_iterator-0.2.1}/timeout_iterator/without_terminate.py +5 -2
  12. {timeout-iterator-0.1.1 → timeout_iterator-0.2.1}/timeout_iterator.egg-info/PKG-INFO +18 -8
  13. {timeout-iterator-0.1.1 → timeout_iterator-0.2.1}/timeout_iterator.egg-info/SOURCES.txt +2 -2
  14. timeout_iterator-0.2.1/uv.lock +403 -0
  15. timeout-iterator-0.1.1/poetry.lock +0 -362
  16. timeout-iterator-0.1.1/pyproject.toml +0 -49
  17. timeout-iterator-0.1.1/setup.cfg +0 -34
  18. {timeout-iterator-0.1.1 → timeout_iterator-0.2.1}/.github/dependabot.yml +0 -0
  19. {timeout-iterator-0.1.1 → timeout_iterator-0.2.1}/.github/renovate.json5 +0 -0
  20. {timeout-iterator-0.1.1 → timeout_iterator-0.2.1}/.github/workflows/happy.yml +0 -0
  21. {timeout-iterator-0.1.1 → timeout_iterator-0.2.1}/.github/workflows/spellcheck.yml +0 -0
  22. {timeout-iterator-0.1.1 → timeout_iterator-0.2.1}/.gitignore +0 -0
  23. {timeout-iterator-0.1.1 → timeout_iterator-0.2.1}/.gitignore.in +0 -0
  24. {timeout-iterator-0.1.1 → timeout_iterator-0.2.1}/README.md +0 -0
  25. {timeout-iterator-0.1.1 → timeout_iterator-0.2.1}/tests/__init__.py +0 -0
  26. {timeout-iterator-0.1.1 → timeout_iterator-0.2.1}/tests/test_without_terminate.py +0 -0
  27. {timeout-iterator-0.1.1 → timeout_iterator-0.2.1}/timeout_iterator/__init__.py +0 -0
  28. {timeout-iterator-0.1.1 → timeout_iterator-0.2.1}/timeout_iterator.egg-info/dependency_links.txt +0 -0
  29. {timeout-iterator-0.1.1 → timeout_iterator-0.2.1}/timeout_iterator.egg-info/top_level.txt +0 -0
@@ -13,4 +13,4 @@ jobs:
13
13
  update-gitignore:
14
14
  runs-on: ubuntu-latest
15
15
  steps:
16
- - uses: gitignore-in/gh-action@v0.2.0
16
+ - uses: gitignore-in/gh-action@v0.2.2
@@ -8,7 +8,7 @@ on:
8
8
  types: [prereleased, released]
9
9
 
10
10
  env:
11
- python_version: 3.12
11
+ python_version: 3.13
12
12
 
13
13
  jobs:
14
14
  deploy:
@@ -22,24 +22,16 @@ jobs:
22
22
  with:
23
23
  python-version: ${{ env.python_version }}
24
24
 
25
- - name: Set up poetry
26
- uses: abatilo/actions-poetry@v2
25
+ - name: Set up uv
26
+ uses: astral-sh/setup-uv@v5
27
27
 
28
- - name: Cache
29
- uses: actions/cache@v3
30
- with:
31
- path: ~/.cache/pypoetry/virtualenvs
32
- key: ${{ runner.os }}-build-${{ env.python_version }}-${{ hashFiles('**/poetry.lock') }}
33
- restore-keys: |
34
- ${{ runner.os }}-build-${{ env.python_version }}-${{ hashFiles('**/poetry.lock') }}
35
- ${{ runner.os }}-build-${{ env.python_version }}-
36
- ${{ runner.os }}-
37
-
38
- - run: poetry install
28
+ - name: Install dependencies
29
+ run: |
30
+ uv python pin ${{ env.python_version }}
31
+ uv sync
39
32
 
40
33
  - name: Build
41
- # I use poetry just as a package manager, so this is not `poetry build`
42
- run: poetry run poe build
34
+ run: uv build
43
35
 
44
36
  - name: Publish distribution to Test PyPI
45
37
  uses: pypa/gh-action-pypi-publish@release/v1
@@ -1,14 +1,19 @@
1
1
  name: Test
2
2
  on:
3
- - pull_request
4
-
3
+ # pull-request events are not triggered when a PR is merged
4
+ # push events are not triggered when a PR created from a fork repository
5
+ # So we need both to run tests on every PR and after merging
6
+ pull_request:
7
+ push:
8
+ branches:
9
+ - main
5
10
  jobs:
6
11
  test:
7
12
  runs-on: ubuntu-latest
8
13
  strategy:
9
14
  fail-fast: false
10
15
  matrix:
11
- python: ["3.8", "3.9", "3.10", "3.11", "3.12"]
16
+ python: ["3.9", "3.10", "3.11", "3.12", "3.13"]
12
17
 
13
18
  steps:
14
19
  - name: Checkout
@@ -20,28 +25,18 @@ jobs:
20
25
  with:
21
26
  python-version: "${{ matrix.python }}"
22
27
 
23
- - name: Set up poetry
24
- uses: abatilo/actions-poetry@v2
25
-
26
- - name: Cache
27
- uses: actions/cache@v3
28
- with:
29
- path: ~/.cache/pypoetry/virtualenvs
30
- key: ${{ runner.os }}-build-${{ matrix.python }}-${{ hashFiles('**/poetry.lock') }}
31
- restore-keys: |
32
- ${{ runner.os }}-build-${{ matrix.python }}-${{ hashFiles('**/poetry.lock') }}
33
- ${{ runner.os }}-build-${{ matrix.python }}-
34
- ${{ runner.os }}-
28
+ - name: Set up uv
29
+ uses: astral-sh/setup-uv@v5
35
30
 
36
31
  - name: Install dependencies
37
- run: poetry install
32
+ run: uv sync
38
33
 
39
34
  - name: Lint
40
- run: poetry run poe check
35
+ run: uv run poe check
41
36
 
42
37
  - name: Check Python version
43
38
  run: |
44
- actual_version=$(poetry run python --version)
39
+ actual_version=$(uv run python --version)
45
40
  expected_version="Python ${{ matrix.python }}"
46
41
  if [ "$actual_version" == *"$expected_version"* ]; then
47
42
  echo "Expected $expected_version, but got $actual_version"
@@ -49,14 +44,14 @@ jobs:
49
44
  fi
50
45
 
51
46
  - name: Test
52
- run: poetry run poe test
47
+ run: uv run poe test
53
48
 
54
49
  - name: Coverage
55
- run: poetry run poe coverage-xml
50
+ run: uv run poe coverage-xml
56
51
 
57
52
  - name: Upload coverage report to Codecov
58
- if: matrix.python == '3.12'
59
- uses: codecov/codecov-action@v3
53
+ if: matrix.python == '3.13'
54
+ uses: codecov/codecov-action@v5
60
55
  with:
61
56
  token: ${{ secrets.CODECOV_TOKEN }}
62
57
  files: ./coverage.xml
@@ -0,0 +1,11 @@
1
+ Copyright 2024-2025 Kitsu Yui
2
+
3
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4
+
5
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6
+
7
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8
+
9
+ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10
+
11
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -1,22 +1,32 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: timeout-iterator
3
- Version: 0.1.1
3
+ Version: 0.2.1
4
4
  Summary: Iterator with timeout
5
- Home-page: https://github.com/kitsuyui/python-timeout-iterator
6
- Author: Yui Kitsu
7
- Author-email: kitsuyui+github@kitsuyui.com
8
- License: BSD-3-Clause
5
+ Author-email: Yui KITSU <kitsuyui+github@kitsuyui.com>
6
+ License: Copyright 2024-2025 Kitsu Yui
7
+
8
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
9
+
10
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
11
+
12
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
13
+
14
+ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17
+ Project-URL: Homepage, https://github.com/kitsuyui/python-timeout-iterator
9
18
  Classifier: Development Status :: 3 - Alpha
10
19
  Classifier: License :: OSI Approved :: BSD License
11
- Classifier: Programming Language :: Python :: 3.8
12
20
  Classifier: Programming Language :: Python :: 3.9
13
21
  Classifier: Programming Language :: Python :: 3.10
14
22
  Classifier: Programming Language :: Python :: 3.11
15
23
  Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Programming Language :: Python :: 3.13
16
25
  Classifier: Intended Audience :: Developers
17
26
  Classifier: Topic :: Software Development :: Libraries
18
- Requires-Python: >=3.8
27
+ Requires-Python: >=3.9
19
28
  Description-Content-Type: text/markdown
29
+ License-File: LICENSE
20
30
 
21
31
  # python-timeout-iterator
22
32
 
@@ -0,0 +1,65 @@
1
+ [project]
2
+ name = "timeout-iterator"
3
+ dynamic = ["version"]
4
+ requires-python = ">=3.9"
5
+ dependencies = []
6
+ description = "Iterator with timeout"
7
+ readme = {file = "README.md", content-type = "text/markdown"}
8
+ license = { file = "LICENSE" }
9
+ authors = [
10
+ {name = "Yui KITSU", email = "kitsuyui+github@kitsuyui.com"}
11
+ ]
12
+ classifiers = [
13
+ "Development Status :: 3 - Alpha",
14
+ "License :: OSI Approved :: BSD License",
15
+ "Programming Language :: Python :: 3.9",
16
+ "Programming Language :: Python :: 3.10",
17
+ "Programming Language :: Python :: 3.11",
18
+ "Programming Language :: Python :: 3.12",
19
+ "Programming Language :: Python :: 3.13",
20
+ "Intended Audience :: Developers",
21
+ "Topic :: Software Development :: Libraries",
22
+ ]
23
+
24
+ [project.urls]
25
+ Homepage = "https://github.com/kitsuyui/python-timeout-iterator"
26
+
27
+ [tool.setuptools]
28
+ package-data = { "timeout_iterator" = ["py.typed"], "*" = ["README.md, LICENSE"] }
29
+ package-dir = { "timeout_iterator" = "timeout_iterator" }
30
+
31
+ [tool.uv]
32
+ dev-dependencies = [
33
+ "pytest",
34
+ "pytest-cov",
35
+ "poethepoet",
36
+ "setuptools-scm",
37
+ "ruff",
38
+ "mypy",
39
+ ]
40
+
41
+ [build-system]
42
+ requires = ["setuptools", "setuptools_scm"]
43
+ build-backend = "setuptools.build_meta"
44
+
45
+ [tool.setuptools_scm]
46
+ write_to = "timeout_iterator/_version.py"
47
+ version_scheme = "only-version"
48
+ local_scheme = "no-local-version"
49
+
50
+ [tool.poe.tasks]
51
+ test = "pytest"
52
+ coverage-xml = "pytest --cov=timeout_iterator --doctest-modules --cov-report=xml"
53
+ format = "ruff format timeout_iterator tests"
54
+ check = [
55
+ { cmd = "ruff check timeout_iterator tests" },
56
+ { cmd = "mypy timeout_iterator tests" },
57
+ ]
58
+ build = "python -m build"
59
+
60
+ [tool.mypy]
61
+ strict = true
62
+ ignore_missing_imports = false
63
+
64
+ [tool.ruff]
65
+ line-length = 79
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -1,3 +1,4 @@
1
+ import signal
1
2
  import time
2
3
 
3
4
  import pytest
@@ -24,3 +25,25 @@ def test_terminate_2() -> None:
24
25
  time.sleep(0.1)
25
26
 
26
27
  assert results == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
28
+
29
+
30
+ def test_terminate_3() -> None:
31
+ # Do not timeout if the sent signal is not SIGALRM
32
+ results = []
33
+ for i in terminate(range(10), seconds=3.0):
34
+ results.append(i)
35
+ time.sleep(0.1)
36
+ signal.alarm(signal.SIGWINCH)
37
+
38
+ assert results == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
39
+
40
+
41
+ def test_terminate_4() -> None:
42
+ # Do not timeout if the signal sent but the time is longer than the timeout
43
+ results = []
44
+ for i in terminate(range(10), seconds=3.0):
45
+ results.append(i)
46
+ time.sleep(0.1)
47
+ signal.alarm(signal.SIGALRM)
48
+
49
+ assert results == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.1.1'
16
- __version_tuple__ = version_tuple = (0, 1, 1)
15
+ __version__ = version = '0.2.1'
16
+ __version_tuple__ = version_tuple = (0, 2, 1)
@@ -1,11 +1,14 @@
1
- from collections.abc import Iterable
1
+ from typing import TypeVar, Iterable
2
2
  import datetime
3
3
  import signal
4
4
 
5
5
 
6
+ T = TypeVar("T")
7
+
8
+
6
9
  # NOTE: float type accepts int
7
10
  # https://peps.python.org/pep-0484/#the-numeric-tower
8
- def terminate(iterable: Iterable, seconds: float) -> Iterable:
11
+ def terminate(iterable: Iterable[T], seconds: float) -> Iterable[T]:
9
12
  """Timeout iterator
10
13
 
11
14
  This iterator forcibly terminates a running task after the specified number of seconds.
@@ -1,10 +1,13 @@
1
- from collections.abc import Iterable
1
+ from typing import TypeVar, Iterable
2
2
  import datetime
3
3
 
4
4
 
5
+ T = TypeVar("T")
6
+
7
+
5
8
  # NOTE: float type accepts int
6
9
  # https://peps.python.org/pep-0484/#the-numeric-tower
7
- def without_terminate(iterable: Iterable, seconds: float) -> Iterable:
10
+ def without_terminate(iterable: Iterable[T], seconds: float) -> Iterable[T]:
8
11
  """Timeout iterator
9
12
 
10
13
  This iterator times out after the specified number of seconds.
@@ -1,22 +1,32 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: timeout-iterator
3
- Version: 0.1.1
3
+ Version: 0.2.1
4
4
  Summary: Iterator with timeout
5
- Home-page: https://github.com/kitsuyui/python-timeout-iterator
6
- Author: Yui Kitsu
7
- Author-email: kitsuyui+github@kitsuyui.com
8
- License: BSD-3-Clause
5
+ Author-email: Yui KITSU <kitsuyui+github@kitsuyui.com>
6
+ License: Copyright 2024-2025 Kitsu Yui
7
+
8
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
9
+
10
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
11
+
12
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
13
+
14
+ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17
+ Project-URL: Homepage, https://github.com/kitsuyui/python-timeout-iterator
9
18
  Classifier: Development Status :: 3 - Alpha
10
19
  Classifier: License :: OSI Approved :: BSD License
11
- Classifier: Programming Language :: Python :: 3.8
12
20
  Classifier: Programming Language :: Python :: 3.9
13
21
  Classifier: Programming Language :: Python :: 3.10
14
22
  Classifier: Programming Language :: Python :: 3.11
15
23
  Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Programming Language :: Python :: 3.13
16
25
  Classifier: Intended Audience :: Developers
17
26
  Classifier: Topic :: Software Development :: Libraries
18
- Requires-Python: >=3.8
27
+ Requires-Python: >=3.9
19
28
  Description-Content-Type: text/markdown
29
+ License-File: LICENSE
20
30
 
21
31
  # python-timeout-iterator
22
32
 
@@ -1,9 +1,9 @@
1
1
  .gitignore
2
2
  .gitignore.in
3
+ LICENSE
3
4
  README.md
4
- poetry.lock
5
5
  pyproject.toml
6
- setup.cfg
6
+ uv.lock
7
7
  .github/dependabot.yml
8
8
  .github/renovate.json5
9
9
  .github/workflows/gitignore-in.yml