pyobs-v4l 2.0.0.dev6__tar.gz → 2.1.0__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 (26) hide show
  1. {pyobs_v4l-2.0.0.dev6 → pyobs_v4l-2.1.0}/PKG-INFO +3 -3
  2. pyobs_v4l-2.1.0/pyobs_v4l/v4lcamera.py +193 -0
  3. {pyobs_v4l-2.0.0.dev6 → pyobs_v4l-2.1.0}/pyproject.toml +3 -3
  4. pyobs_v4l-2.1.0/tests/test_v4lcamera.py +127 -0
  5. {pyobs_v4l-2.0.0.dev6 → pyobs_v4l-2.1.0}/uv.lock +40 -40
  6. pyobs_v4l-2.0.0.dev6/pyobs_v4l/v4lcamera.py +0 -131
  7. pyobs_v4l-2.0.0.dev6/tests/test_v4lcamera.py +0 -45
  8. {pyobs_v4l-2.0.0.dev6 → pyobs_v4l-2.1.0}/.github/dependabot.yml +0 -0
  9. {pyobs_v4l-2.0.0.dev6 → pyobs_v4l-2.1.0}/.github/workflows/dependabot-automerge.yml +0 -0
  10. {pyobs_v4l-2.0.0.dev6 → pyobs_v4l-2.1.0}/.github/workflows/pypi.yml +0 -0
  11. {pyobs_v4l-2.0.0.dev6 → pyobs_v4l-2.1.0}/.github/workflows/pyrefly.yml +0 -0
  12. {pyobs_v4l-2.0.0.dev6 → pyobs_v4l-2.1.0}/.github/workflows/pytest.yml +0 -0
  13. {pyobs_v4l-2.0.0.dev6 → pyobs_v4l-2.1.0}/.github/workflows/ruff.yml +0 -0
  14. {pyobs_v4l-2.0.0.dev6 → pyobs_v4l-2.1.0}/.pre-commit-config.yaml +0 -0
  15. {pyobs_v4l-2.0.0.dev6 → pyobs_v4l-2.1.0}/.readthedocs.yml +0 -0
  16. {pyobs_v4l-2.0.0.dev6 → pyobs_v4l-2.1.0}/LICENSE +0 -0
  17. {pyobs_v4l-2.0.0.dev6 → pyobs_v4l-2.1.0}/README.md +0 -0
  18. {pyobs_v4l-2.0.0.dev6 → pyobs_v4l-2.1.0}/docs/Makefile +0 -0
  19. {pyobs_v4l-2.0.0.dev6 → pyobs_v4l-2.1.0}/docs/make.bat +0 -0
  20. {pyobs_v4l-2.0.0.dev6 → pyobs_v4l-2.1.0}/docs/requirements.txt +0 -0
  21. {pyobs_v4l-2.0.0.dev6 → pyobs_v4l-2.1.0}/docs/source/_static/pyobs.gif +0 -0
  22. {pyobs_v4l-2.0.0.dev6 → pyobs_v4l-2.1.0}/docs/source/conf.py +0 -0
  23. {pyobs_v4l-2.0.0.dev6 → pyobs_v4l-2.1.0}/docs/source/index.rst +0 -0
  24. {pyobs_v4l-2.0.0.dev6 → pyobs_v4l-2.1.0}/pyobs_v4l/__init__.py +0 -0
  25. {pyobs_v4l-2.0.0.dev6 → pyobs_v4l-2.1.0}/pyobs_v4l/gui.py +0 -0
  26. {pyobs_v4l-2.0.0.dev6 → pyobs_v4l-2.1.0}/tests/test_import.py +0 -0
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: pyobs-v4l
3
- Version: 2.0.0.dev6
3
+ Version: 2.1.0
4
4
  Summary: pyobs module for V4L cameras
5
5
  Author-email: Tim-Oliver Husser <thusser@uni-goettingen.de>
6
6
  License-Expression: MIT
7
7
  License-File: LICENSE
8
8
  Requires-Python: >=3.11
9
9
  Requires-Dist: opencv-python<6,>=4.0
10
- Requires-Dist: pyobs-core<3,>=2.0.0.dev48
10
+ Requires-Dist: pyobs-core<3,>=2.13.1
11
11
  Provides-Extra: gui
12
- Requires-Dist: pyobs-core[gui]<3,>=2.0.0.dev48; extra == 'gui'
12
+ Requires-Dist: pyobs-core[gui]<3,>=2.13.1; extra == 'gui'
@@ -0,0 +1,193 @@
1
+ import asyncio
2
+ import logging
3
+ import threading
4
+ from collections.abc import AsyncGenerator, Callable
5
+ from typing import Any
6
+
7
+ import cv2
8
+ from pyobs.modules.camera import BaseVideo, Frame
9
+
10
+ log = logging.getLogger(__name__)
11
+
12
+ # cv2's V4L2 backend calls are blocking and are made directly on the event loop thread (see
13
+ # _run_blocking). If the camera has gone unresponsive, they can hang indefinitely, so they're
14
+ # bounded with a timeout rather than let a single dead camera freeze the whole module.
15
+ _SDK_CALL_TIMEOUT = 5.0
16
+
17
+ # frames() warns if no frame arrived for this long. Frames legitimately take up to the camera's
18
+ # own frame interval, so this is much more generous than _SDK_CALL_TIMEOUT.
19
+ _FRAME_WAIT_TIMEOUT = 30.0
20
+
21
+ # frames queued between the reader thread and the event loop; latest wins beyond that
22
+ _QUEUE_SIZE = 5
23
+
24
+
25
+ class v4lCamera(BaseVideo):
26
+ """A pyobs module for V4L2 cameras, e.g. webcams.
27
+
28
+ The device is opened while the module is active and released when it goes to sleep. V4L2
29
+ gives no reliable exposure time or exposure start via OpenCV, so frames carry neither and
30
+ DATE-OBS is the frame's arrival time.
31
+ """
32
+
33
+ __module__ = "pyobs_v4l"
34
+
35
+ def __init__(self, device: int = 0, color: bool = False, **kwargs: Any):
36
+ """Initializes a new v4lCamera.
37
+
38
+ Args:
39
+ device: Index of the V4L2 device, i.e. N in /dev/videoN.
40
+ color: Keep colour frames (RGB, colour as last axis) instead of converting them to
41
+ greyscale. Colour frames work for the live view, but not for grab_stack(), and
42
+ are stored as 3D FITS files.
43
+ """
44
+ BaseVideo.__init__(self, **kwargs)
45
+
46
+ # store
47
+ self._device = device
48
+ self._color = color
49
+
50
+ async def open(self) -> None:
51
+ """Open module."""
52
+ await BaseVideo.open(self)
53
+
54
+ # start streaming
55
+ await self.activate_camera()
56
+
57
+ @staticmethod
58
+ async def _run_blocking(func: Callable[[], None], timeout: float = _SDK_CALL_TIMEOUT) -> bool:
59
+ """Run a blocking cv2/V4L2 call in a daemon thread, so a hung call can't freeze the module.
60
+
61
+ A plain executor isn't used here, since its worker threads are non-daemon and Python joins
62
+ them on interpreter shutdown -- a hung call would then just move the freeze to process exit.
63
+
64
+ Returns:
65
+ True if func completed within timeout, False if it's still running in the background.
66
+ """
67
+ loop = asyncio.get_running_loop()
68
+ future: asyncio.Future[None] = loop.create_future()
69
+
70
+ def _finish() -> None:
71
+ # wait_for cancels the future on timeout, so guard set_result to avoid an
72
+ # InvalidStateError from the loop thread once the orphaned call finally ends.
73
+ if not future.done():
74
+ future.set_result(None)
75
+
76
+ def _wrapper() -> None:
77
+ try:
78
+ func()
79
+ finally:
80
+ try:
81
+ loop.call_soon_threadsafe(_finish)
82
+ except RuntimeError:
83
+ # event loop closed (shutdown)
84
+ pass
85
+
86
+ threading.Thread(target=_wrapper, daemon=True).start()
87
+ try:
88
+ await asyncio.wait_for(future, timeout=timeout)
89
+ return True
90
+ except TimeoutError:
91
+ return False
92
+
93
+ async def _open_camera(self) -> Any:
94
+ """Open the V4L2 camera device, without blocking the event loop.
95
+
96
+ Raises:
97
+ TimeoutError: If opening didn't finish in time.
98
+ RuntimeError: If the device could not be opened.
99
+ """
100
+ result: list[Any] = []
101
+ lock = threading.Lock()
102
+ timed_out = False
103
+
104
+ def _open() -> None:
105
+ camera = cv2.VideoCapture(self._device)
106
+ with lock:
107
+ if timed_out:
108
+ # timed out while still opening; release the handle nobody will use
109
+ camera.release()
110
+ else:
111
+ result.append(camera)
112
+
113
+ if not await self._run_blocking(_open):
114
+ with lock:
115
+ timed_out = True
116
+ if result:
117
+ result.pop().release()
118
+ raise TimeoutError(f"Timed out opening camera device after {_SDK_CALL_TIMEOUT}s.")
119
+
120
+ # VideoCapture() doesn't raise for a missing/busy device, it just isn't opened
121
+ camera = result[0]
122
+ if not camera.isOpened():
123
+ camera.release()
124
+ raise RuntimeError(f"Could not open camera device {self._device}.")
125
+ return camera
126
+
127
+ def _convert(self, frame: Any) -> Any:
128
+ """Convert a frame from OpenCV's BGR to greyscale, or to RGB if colour is kept."""
129
+ if frame.ndim != 3:
130
+ return frame
131
+ return cv2.cvtColor(frame, cv2.COLOR_BGR2RGB if self._color else cv2.COLOR_BGR2GRAY)
132
+
133
+ async def frames(self) -> AsyncGenerator[Frame, None]:
134
+ """Open the device and yield frames until BaseVideo closes the iterator.
135
+
136
+ A single reader thread owns the device for the whole activation, reads frames and hands
137
+ them to the event loop, and releases the device when it's told to stop. A failed read ends
138
+ the iterator with an error, so BaseVideo restarts it with a back-off.
139
+ """
140
+ loop = asyncio.get_running_loop()
141
+ queue: asyncio.Queue[Frame | BaseException] = asyncio.Queue(maxsize=_QUEUE_SIZE)
142
+ stop = threading.Event()
143
+ camera = await self._open_camera()
144
+
145
+ def _put(item: Frame | BaseException) -> None:
146
+ # latest wins: a stalled event loop mustn't grow memory
147
+ if queue.full():
148
+ queue.get_nowait()
149
+ queue.put_nowait(item)
150
+
151
+ def _read() -> None:
152
+ try:
153
+ while not stop.is_set():
154
+ item: Frame | BaseException
155
+ try:
156
+ # read() returns a fresh array per call, so no copy needed
157
+ ok, frame = camera.read()
158
+ if ok and frame is not None:
159
+ item = Frame(data=self._convert(frame))
160
+ else:
161
+ item = RuntimeError(f"Could not read frame from camera device {self._device}.")
162
+ except Exception as e:
163
+ item = e
164
+ if stop.is_set():
165
+ return
166
+ try:
167
+ loop.call_soon_threadsafe(_put, item)
168
+ except RuntimeError:
169
+ # event loop closed (shutdown)
170
+ return
171
+ if isinstance(item, BaseException):
172
+ return
173
+ finally:
174
+ camera.release()
175
+
176
+ threading.Thread(target=_read, daemon=True).start()
177
+ try:
178
+ while True:
179
+ try:
180
+ item = await asyncio.wait_for(queue.get(), timeout=_FRAME_WAIT_TIMEOUT)
181
+ except TimeoutError:
182
+ log.warning("No frame from camera for %.1fs.", _FRAME_WAIT_TIMEOUT)
183
+ continue
184
+ if isinstance(item, BaseException):
185
+ raise item
186
+ yield item
187
+ finally:
188
+ # don't join the reader: if it hangs in read(), it must not block deactivation; it
189
+ # releases the device itself once read() returns
190
+ stop.set()
191
+
192
+
193
+ __all__ = ["v4lCamera"]
@@ -1,18 +1,18 @@
1
1
  [project]
2
2
  name = "pyobs-v4l"
3
- version = "2.0.0.dev6"
3
+ version = "2.1.0"
4
4
  description = "pyobs module for V4L cameras"
5
5
  authors = [{ name = "Tim-Oliver Husser", email = "thusser@uni-goettingen.de" }]
6
6
  requires-python = ">=3.11"
7
7
  license = "MIT"
8
8
  dependencies = [
9
9
  "opencv-python>=4.0,<6",
10
- "pyobs-core>=2.0.0.dev48,<3",
10
+ "pyobs-core>=2.13.1,<3",
11
11
  ]
12
12
 
13
13
  [project.optional-dependencies]
14
14
  gui = [
15
- "pyobs-core[gui]>=2.0.0.dev48,<3",
15
+ "pyobs-core[gui]>=2.13.1,<3",
16
16
  ]
17
17
 
18
18
  [project.scripts]
@@ -0,0 +1,127 @@
1
+ """Unit tests for the non-hardware logic in v4lCamera: constructor state, the _run_blocking
2
+ timeout wrapper, device opening and frames(). cv2.VideoCapture is replaced by a fake.
3
+ """
4
+
5
+ import asyncio
6
+ import threading
7
+ from typing import Any
8
+
9
+ import cv2
10
+ import numpy as np
11
+ import numpy.typing as npt
12
+ import pytest
13
+
14
+ from pyobs_v4l import v4lCamera
15
+
16
+
17
+ class FakeCapture:
18
+ """Stands in for cv2.VideoCapture: frames come from a list, a failed read once it's empty."""
19
+
20
+ def __init__(self, frames: list[npt.NDArray[Any]] | None = None, opened: bool = True) -> None:
21
+ self.frames = [] if frames is None else frames
22
+ self.opened = opened
23
+ self.released = threading.Event()
24
+
25
+ def isOpened(self) -> bool:
26
+ return self.opened
27
+
28
+ def read(self) -> tuple[bool, npt.NDArray[Any] | None]:
29
+ if self.frames:
30
+ return True, self.frames.pop(0)
31
+ return False, None
32
+
33
+ def release(self) -> None:
34
+ self.released.set()
35
+
36
+
37
+ def _bgr(b: int, g: int, r: int) -> npt.NDArray[Any]:
38
+ frame = np.zeros((2, 3, 3), dtype=np.uint8)
39
+ frame[:, :] = (b, g, r)
40
+ return frame
41
+
42
+
43
+ def test_constructor_defaults() -> None:
44
+ camera = v4lCamera()
45
+ assert camera._device == 0
46
+ assert camera._color is False
47
+
48
+
49
+ def test_constructor_device() -> None:
50
+ camera = v4lCamera(device=3)
51
+ assert camera._device == 3
52
+
53
+
54
+ @pytest.mark.asyncio
55
+ async def test_run_blocking_runs_func_and_returns_true() -> None:
56
+ ran: list[bool] = []
57
+
58
+ def fast() -> None:
59
+ ran.append(True)
60
+
61
+ assert await v4lCamera._run_blocking(fast) is True
62
+ assert ran == [True]
63
+
64
+
65
+ @pytest.mark.asyncio
66
+ async def test_run_blocking_times_out() -> None:
67
+ done = threading.Event()
68
+
69
+ def slow() -> None:
70
+ done.wait()
71
+
72
+ assert await v4lCamera._run_blocking(slow, timeout=0.01) is False
73
+ done.set()
74
+ await asyncio.sleep(0.05) # let the daemon thread drain before the loop closes
75
+
76
+
77
+ @pytest.mark.asyncio
78
+ async def test_open_camera_raises_if_not_opened(monkeypatch: pytest.MonkeyPatch) -> None:
79
+ fake = FakeCapture(opened=False)
80
+ monkeypatch.setattr(cv2, "VideoCapture", lambda device: fake)
81
+
82
+ with pytest.raises(RuntimeError, match="Could not open"):
83
+ await v4lCamera()._open_camera()
84
+ assert fake.released.is_set()
85
+
86
+
87
+ @pytest.mark.asyncio
88
+ async def test_frames_yields_greyscale_and_releases_on_close(monkeypatch: pytest.MonkeyPatch) -> None:
89
+ fake = FakeCapture([_bgr(0, 0, 255), _bgr(255, 0, 0)] + [_bgr(0, 0, 0)] * 100)
90
+ monkeypatch.setattr(cv2, "VideoCapture", lambda device: fake)
91
+ camera = v4lCamera()
92
+
93
+ iterator = camera.frames()
94
+ first, second = await anext(iterator), await anext(iterator)
95
+ await iterator.aclose()
96
+
97
+ assert first.data.shape == (2, 3) and second.data.shape == (2, 3)
98
+ # BGR, not RGB: pure red is brighter than pure blue in greyscale
99
+ assert int(first.data[0, 0]) > int(second.data[0, 0])
100
+ assert first.start is None and first.exposure_time is None
101
+ assert fake.released.wait(1.0)
102
+
103
+
104
+ @pytest.mark.asyncio
105
+ async def test_frames_keeps_colour_as_rgb(monkeypatch: pytest.MonkeyPatch) -> None:
106
+ fake = FakeCapture([_bgr(1, 2, 3)] * 10)
107
+ monkeypatch.setattr(cv2, "VideoCapture", lambda device: fake)
108
+ camera = v4lCamera(color=True)
109
+
110
+ iterator = camera.frames()
111
+ frame = await anext(iterator)
112
+ await iterator.aclose()
113
+
114
+ assert frame.data.shape == (2, 3, 3)
115
+ assert tuple(frame.data[0, 0]) == (3, 2, 1)
116
+
117
+
118
+ @pytest.mark.asyncio
119
+ async def test_frames_raises_on_failed_read(monkeypatch: pytest.MonkeyPatch) -> None:
120
+ fake = FakeCapture([])
121
+ monkeypatch.setattr(cv2, "VideoCapture", lambda device: fake)
122
+ camera = v4lCamera()
123
+
124
+ iterator = camera.frames()
125
+ with pytest.raises(RuntimeError, match="Could not read frame"):
126
+ await anext(iterator)
127
+ assert fake.released.wait(1.0)
@@ -2340,7 +2340,7 @@ wheels = [
2340
2340
 
2341
2341
  [[package]]
2342
2342
  name = "pyobs-core"
2343
- version = "2.0.0.dev72"
2343
+ version = "2.13.1"
2344
2344
  source = { registry = "https://pypi.org/simple" }
2345
2345
  dependencies = [
2346
2346
  { name = "aiohttp" },
@@ -2372,9 +2372,9 @@ dependencies = [
2372
2372
  { name = "tenacity" },
2373
2373
  { name = "typing-extensions" },
2374
2374
  ]
2375
- sdist = { url = "https://files.pythonhosted.org/packages/d7/25/ac1a0571461eb87655374a38a4a21983db407f7239d60adce009e4ba8438/pyobs_core-2.0.0.dev72.tar.gz", hash = "sha256:b9ac8679bb9a72d1180ba60a97ad08b1878b1bc6b21158754d1f7fc7033231ee", size = 354347, upload-time = "2026-08-10T11:31:59.746Z" }
2375
+ sdist = { url = "https://files.pythonhosted.org/packages/b2/43/99e30a5a0e42bc49396b876b945ff8c0b8320141f5dcaea959a329c42eaf/pyobs_core-2.13.1.tar.gz", hash = "sha256:54001d7e096dfec2ab1a90cad5d45d35b0d74a28c679266eb88feb1c4045a34f", size = 450687, upload-time = "2026-09-29T08:48:42.267Z" }
2376
2376
  wheels = [
2377
- { url = "https://files.pythonhosted.org/packages/8e/6a/570856f6149a611d7e4858e980faa1e23c5ddedda22327808f8e3eb5b413/pyobs_core-2.0.0.dev72-py3-none-any.whl", hash = "sha256:321f6b80f2fb8703e3cbf2f62cea2333cb475b1a50f58d8900176644fe6ca6b2", size = 576647, upload-time = "2026-08-10T11:31:57.813Z" },
2377
+ { url = "https://files.pythonhosted.org/packages/6a/18/c9eab05e2e78ec6554c4166f1decde3f6274ab6529c9459ee796acff9bfc/pyobs_core-2.13.1-py3-none-any.whl", hash = "sha256:3afd1de36f35d87f49baca1ab0360d1a2f36cd313e29027fdb5679c4f52df897", size = 689504, upload-time = "2026-09-29T08:48:40.59Z" },
2378
2378
  ]
2379
2379
 
2380
2380
  [package.optional-dependencies]
@@ -2386,7 +2386,7 @@ gui = [
2386
2386
 
2387
2387
  [[package]]
2388
2388
  name = "pyobs-v4l"
2389
- version = "2.0.0.dev6"
2389
+ version = "2.1.0"
2390
2390
  source = { editable = "." }
2391
2391
  dependencies = [
2392
2392
  { name = "opencv-python" },
@@ -2411,8 +2411,8 @@ dev = [
2411
2411
  [package.metadata]
2412
2412
  requires-dist = [
2413
2413
  { name = "opencv-python", specifier = ">=4.0,<6" },
2414
- { name = "pyobs-core", specifier = ">=2.0.0.dev48,<3" },
2415
- { name = "pyobs-core", extras = ["gui"], marker = "extra == 'gui'", specifier = ">=2.0.0.dev48,<3" },
2414
+ { name = "pyobs-core", specifier = ">=2.13.1,<3" },
2415
+ { name = "pyobs-core", extras = ["gui"], marker = "extra == 'gui'", specifier = ">=2.13.1,<3" },
2416
2416
  ]
2417
2417
  provides-extras = ["gui"]
2418
2418
 
@@ -2437,21 +2437,21 @@ wheels = [
2437
2437
 
2438
2438
  [[package]]
2439
2439
  name = "pyrefly"
2440
- version = "1.2.0"
2440
+ version = "1.3.1"
2441
2441
  source = { registry = "https://pypi.org/simple" }
2442
- sdist = { url = "https://files.pythonhosted.org/packages/89/01/a86e9f24722b095c3f88e3616132b75a21b0df53804bdc6a45314dd4d93c/pyrefly-1.2.0.tar.gz", hash = "sha256:5485f960fc2481617068c918335c39ab1507ef90b6b5bd35bf57726e60e73185", size = 6243654, upload-time = "2026-08-01T02:56:27.592Z" }
2442
+ sdist = { url = "https://files.pythonhosted.org/packages/4c/7e/082cc1b392318bacfbc087732524f3e089e9e7fe45b7645c4649b6f1f1e9/pyrefly-1.3.1.tar.gz", hash = "sha256:b774f1dfac82867fc16fe2175d80a630e2a72a6835d5b7e492568d6bfb6b05e7", size = 6679145, upload-time = "2026-09-15T05:09:34.49Z" }
2443
2443
  wheels = [
2444
- { url = "https://files.pythonhosted.org/packages/7d/9d/3c0ef1d4843987b22f996ed381ec9cf5a3b1273e29804db276252e4c95eb/pyrefly-1.2.0-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:7f46d983ac49ddd2b043694960a01dc6a19a5cfd8eec609d6bd9c42866f91b4e", size = 14026305, upload-time = "2026-08-01T02:56:02.611Z" },
2445
- { url = "https://files.pythonhosted.org/packages/0a/06/03bbb78fbea54cdc65b626619f3597d5611aca4fdef11e72a4e8360e7e63/pyrefly-1.2.0-py3-none-macosx_11_0_arm64.whl", hash = "sha256:756f669b5555090f5c1a4fef30db1785fabe657764f7e4e6dc88994dfb8ca82d", size = 13463880, upload-time = "2026-08-01T02:56:04.93Z" },
2446
- { url = "https://files.pythonhosted.org/packages/13/5a/7d8bc00a38e93bbc9c3e7bd14d305f7948717e667c9bcddeab9dd42fd255/pyrefly-1.2.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e3465812ce5ef4781fb592edbf2724547296f0a3124be115d73c7e8b2401862d", size = 13907329, upload-time = "2026-08-01T02:56:07.104Z" },
2447
- { url = "https://files.pythonhosted.org/packages/be/94/9e08b4bf799d0b8f36b55a2783c7ba5f51730cf0632a85a67b5b5ed876cd/pyrefly-1.2.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:5de7b2ad2bba5c8055181681a84b74143eac2234a48ba5d1b7ed7e7a722b02bd", size = 15039020, upload-time = "2026-08-01T02:56:09.208Z" },
2448
- { url = "https://files.pythonhosted.org/packages/5b/bd/bca5fd0c80f4daf8ee6903a29df9f3de1feb05ff0946b8f35ec8c5096b13/pyrefly-1.2.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:25822ea9505f589ea8a725e4268b475132fb89e038fbf092e446510443ac142a", size = 14986199, upload-time = "2026-08-01T02:56:11.924Z" },
2449
- { url = "https://files.pythonhosted.org/packages/97/f7/f07087f3d185ad2eced0c56cef89ca5474dfb4ff25f146cd50a861c97553/pyrefly-1.2.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:90efe75e17491ef5d636e10469e9278d7d0256b3b4c5e1f4750069bf3ae0f5d1", size = 14393715, upload-time = "2026-08-01T02:56:14.143Z" },
2450
- { url = "https://files.pythonhosted.org/packages/d3/70/0d142c320e284b9e3ce35e9b1e58b8ce2ee1f578f2a7234bc30e5022b94f/pyrefly-1.2.0-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:368aaf7eee4f511ddc0f8e564cf14e01ab2f10b0db9105c6d5b153bf498d07bf", size = 13933008, upload-time = "2026-08-01T02:56:16.525Z" },
2451
- { url = "https://files.pythonhosted.org/packages/5d/e8/e84f11b6e1f63fd453ad3654213b9a0f6f4de8cef6b58038eef2d0d5955d/pyrefly-1.2.0-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:d52d5da7bc65fb7675fbaa80eda879d4f8787c494f04cac21603330d3abbdbbe", size = 14431827, upload-time = "2026-08-01T02:56:18.645Z" },
2452
- { url = "https://files.pythonhosted.org/packages/0f/06/810d31380f66c75e1c0779a408d3b16117b1b368b57894f6aa66bef21686/pyrefly-1.2.0-py3-none-win32.whl", hash = "sha256:8c90751de8506d938e8f802659c74cf35bd7a0036510ee6c634a38eebb280bfa", size = 13229447, upload-time = "2026-08-01T02:56:20.921Z" },
2453
- { url = "https://files.pythonhosted.org/packages/ed/98/4dafa3c7a1caed2dc8cc708dde09ba27963c7736508f55b626fff3024113/pyrefly-1.2.0-py3-none-win_amd64.whl", hash = "sha256:8a8964c224ccc4882730130955815de21ff443c1ac3f0b90685b19bf63848170", size = 14087387, upload-time = "2026-08-01T02:56:23.188Z" },
2454
- { url = "https://files.pythonhosted.org/packages/1b/1c/df3cb0a2e5591660ded7a1836cd2f29dc48c91adb1c0a3a700a96f6d09e1/pyrefly-1.2.0-py3-none-win_arm64.whl", hash = "sha256:3a90bb8df39dfbac74b1f3b2e9d7c526b8f80568884c3944d955023a73ebf61e", size = 13430873, upload-time = "2026-08-01T02:56:25.425Z" },
2444
+ { url = "https://files.pythonhosted.org/packages/6b/bc/f09b5bd7eed796349bd93627aa2c3086df7ed0a114dafc3d2b2841599ee7/pyrefly-1.3.1-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:0a2a7dfed824fb066aa8a7c8d856c152b98e998fb84b954d5f892fb9834c0bd1", size = 15090117, upload-time = "2026-09-15T05:08:58.477Z" },
2445
+ { url = "https://files.pythonhosted.org/packages/78/24/a31e7de8e0f310c9f0753826d0df8b6a8ff86793941a6bd88ba24b735633/pyrefly-1.3.1-py3-none-macosx_11_0_arm64.whl", hash = "sha256:37a1a1fb41e7190fe3964a877875dd809d6ee2887809e2c3d6e5f25a69805bfd", size = 14430773, upload-time = "2026-09-15T05:09:01.67Z" },
2446
+ { url = "https://files.pythonhosted.org/packages/75/e1/022352beb186f36d6213a95a975c42676ee418ff5e730629378d25564c5e/pyrefly-1.3.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:45b7650bc651a5a784701f2fb4f579da9a421c4d1b5fd91f9048f4529e46093c", size = 14877762, upload-time = "2026-09-15T05:09:04.767Z" },
2447
+ { url = "https://files.pythonhosted.org/packages/19/2c/d62a1b445aad1fd46375b83393b8a67da53883aeeba73d269ce71b3e8fd1/pyrefly-1.3.1-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ad57f38bc73679c14a5f62995a2bd3bc43649b7270c858487e2eab78a6f95362", size = 16118225, upload-time = "2026-09-15T05:09:07.828Z" },
2448
+ { url = "https://files.pythonhosted.org/packages/32/67/3c3fa8a13e3ce8d8322ffb3627255a41a52261f17793e1a24e9214f10857/pyrefly-1.3.1-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3506b1252e9f5d755d0693c5a46d46b85579d36534f6e22a41eb8e098d0dde90", size = 16051197, upload-time = "2026-09-15T05:09:10.81Z" },
2449
+ { url = "https://files.pythonhosted.org/packages/19/d1/84f81b9e32288b5d11c75e006f67e0f6b78b85da575673bd1a21524c8172/pyrefly-1.3.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:39d5a17c1ad655e5f93a6e8e0be90b8db28c6015fe07d6ed4e054891c9e14ef8", size = 15440062, upload-time = "2026-09-15T05:09:14.641Z" },
2450
+ { url = "https://files.pythonhosted.org/packages/46/3c/2aa0c5ad6a2957a728bb38cfab70d1e9cafad21b0b1c1d92df74a3cf22bd/pyrefly-1.3.1-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:c61e9dcf888beb81ca0e0c60ea4442640fdcf2f1f65bfe3d9f5d89b85516eb03", size = 14898534, upload-time = "2026-09-15T05:09:17.823Z" },
2451
+ { url = "https://files.pythonhosted.org/packages/03/5d/2974f249fb2e285f966485719d977c5a2248cc4866403af94d935775ff15/pyrefly-1.3.1-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:a78eed1c53f37807f0e2997be8edbe833b91eb9915f2cb553a1bdcd599e7105c", size = 15477758, upload-time = "2026-09-15T05:09:20.964Z" },
2452
+ { url = "https://files.pythonhosted.org/packages/68/79/d31f8f0abf5b0610ec24183286ee8a1ee5b76c9aaaa91091399d7e1aaf60/pyrefly-1.3.1-py3-none-win32.whl", hash = "sha256:ea0d0349f1bc80fe8e00a7b3640e40db7486398b685f87b9bd5d2207063668f0", size = 14133005, upload-time = "2026-09-15T05:09:25.03Z" },
2453
+ { url = "https://files.pythonhosted.org/packages/3f/23/1859f47f536314755d80c4ec2a76d2698435ae8b73604bcd1dfa57ecb39b/pyrefly-1.3.1-py3-none-win_amd64.whl", hash = "sha256:4c24e7d99df9237916c33be23714219a7c8eaf22bad2ac0c3e1d45adcf7df8fb", size = 15066557, upload-time = "2026-09-15T05:09:28.265Z" },
2454
+ { url = "https://files.pythonhosted.org/packages/92/2a/73e3721921c2bb2c950a9f8c362ee5e2367556b5d4416eb4f8f88503e66f/pyrefly-1.3.1-py3-none-win_arm64.whl", hash = "sha256:1ed85e2b957a78e93353125d890ce3668ce450e49b74025a15c87b6e8ec7f3d1", size = 14348209, upload-time = "2026-09-15T05:09:31.422Z" },
2455
2455
  ]
2456
2456
 
2457
2457
  [[package]]
@@ -2734,27 +2734,27 @@ wheels = [
2734
2734
 
2735
2735
  [[package]]
2736
2736
  name = "ruff"
2737
- version = "0.16.2"
2738
- source = { registry = "https://pypi.org/simple" }
2739
- sdist = { url = "https://files.pythonhosted.org/packages/73/e1/4508a569211b35599016e84ba65c1a992b7a4004b4b6c4bea02a851cba1b/ruff-0.16.2.tar.gz", hash = "sha256:c3d7828d12e8927a6fc65fe38e2c2541b9e762d360a1786d752cb1b8883b3c9c", size = 4885811, upload-time = "2026-08-07T13:31:01.432Z" }
2740
- wheels = [
2741
- { url = "https://files.pythonhosted.org/packages/14/57/db19951540f98859c956b50bdb4d31089b4d91e9f15e2968e7d5193806d5/ruff-0.16.2-py3-none-linux_armv6l.whl", hash = "sha256:3c8de4cf2181f01d57946d87d777aa52916976fc09942aed89938fab5e013318", size = 10847925, upload-time = "2026-08-07T13:30:14.468Z" },
2742
- { url = "https://files.pythonhosted.org/packages/13/5a/995fe85a8470d3e391ac0f7fa8054bb454eaf33ee138196d6172ed1079c0/ruff-0.16.2-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:9a48cc05c6fbc811ca81b5d7ba95375affea6582d1b8024e455e41afbbf55344", size = 11072662, upload-time = "2026-08-07T13:30:18.143Z" },
2743
- { url = "https://files.pythonhosted.org/packages/32/53/370d767c61c71a971a4ace36703a7ecd8c393956349a7325d7fab2b56827/ruff-0.16.2-py3-none-macosx_11_0_arm64.whl", hash = "sha256:a2c0d14fcbb26c91f0f867a6dc9bd71bbc30b1b6151829c884f23faeab2e5700", size = 10566771, upload-time = "2026-08-07T13:30:20.899Z" },
2744
- { url = "https://files.pythonhosted.org/packages/85/d6/9d96948caf5a632be62d62202d5ec914d6856f204fd79eb036e5915e79ea/ruff-0.16.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:335c621622c4650330be50842561c6586ac6971bb8ab5407fe34dcc9efb16bbe", size = 10975825, upload-time = "2026-08-07T13:30:23.517Z" },
2745
- { url = "https://files.pythonhosted.org/packages/3b/92/ea87129b3414acb0b5770563779c51804d37ac67675c7ba35447ddb14773/ruff-0.16.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:20e66910f2c37cc753f9ef6580c914a621b80c4fa3549d3e3521e29d0f5bfc3f", size = 10649437, upload-time = "2026-08-07T13:30:26.097Z" },
2746
- { url = "https://files.pythonhosted.org/packages/ac/43/f8f291dcd4af5bb7872b74fdfa41a7cd7c856ca1d4069670971cf1b9f5cb/ruff-0.16.2-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c7e36fbfba65510548156902bcf1350a979a958ce0347ce0f90d73894036b39f", size = 11446761, upload-time = "2026-08-07T13:30:28.752Z" },
2747
- { url = "https://files.pythonhosted.org/packages/71/4a/ef991fb2fcf516ab71f0808adcdd8da5e18c8cde447f4ceaf5f47a5132a5/ruff-0.16.2-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f0eab35f80df8f134aae5d1630e751901321d317cc8e50dc39e36fa3ed34cd12", size = 12336364, upload-time = "2026-08-07T13:30:31.468Z" },
2748
- { url = "https://files.pythonhosted.org/packages/f3/24/f615e74f307e6ca0e56a482872477b856c70d530aa356abfb6dfe5ca8a80/ruff-0.16.2-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:40ea8c0594feb894e89c8c61ab9c103d38b0ea72dfde6c594107147ca31b1140", size = 11630720, upload-time = "2026-08-07T13:30:34.426Z" },
2749
- { url = "https://files.pythonhosted.org/packages/c5/d3/8ef50149e8412a77f7ab409efdef0e2b23803707a3863da4fc64cb23d459/ruff-0.16.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ab3d62dde0b19facdd632008cc4827fc28ada7736c6bd35ab6f1050f0bfed53f", size = 11466130, upload-time = "2026-08-07T13:30:36.958Z" },
2750
- { url = "https://files.pythonhosted.org/packages/dd/a7/a19334985c4dea8c381981fa252cd854c7ee52dc4b1686dc16f4a911c702/ruff-0.16.2-py3-none-manylinux_2_31_riscv64.whl", hash = "sha256:e43e1f5b8388da9eca1b9e88328d47a5cec794633ccf6f7484ac2dd15eee92c0", size = 11523634, upload-time = "2026-08-07T13:30:39.822Z" },
2751
- { url = "https://files.pythonhosted.org/packages/6e/6c/96d192b0e742412ceda08c0a50f9669b253dde9fd6a60ea1a10c9fa79a63/ruff-0.16.2-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:c24788a980581e1d7ea3a0cbe4344c4fbeb0a6a9b1f4713aa46bb104f8294690", size = 10949807, upload-time = "2026-08-07T13:30:42.745Z" },
2752
- { url = "https://files.pythonhosted.org/packages/fa/51/e26599ceca11e79ee255c7df515995561edf87e9ca1893284e44d98f5a86/ruff-0.16.2-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:81806b08329130005dd4a8a8394a0c9da8c6f4cafb16ba438d2a2ee6a18bedf1", size = 10646891, upload-time = "2026-08-07T13:30:45.522Z" },
2753
- { url = "https://files.pythonhosted.org/packages/68/01/800c4b1f97bc8d7c6029e06b1f20473a3cf1e13c4933d8f3342add83fc55/ruff-0.16.2-py3-none-musllinux_1_2_i686.whl", hash = "sha256:4ce4e02bad779bef557f541a1b31f20d6abeae1cc05ed1b1ac019d4ffd1044c8", size = 11162063, upload-time = "2026-08-07T13:30:48.131Z" },
2754
- { url = "https://files.pythonhosted.org/packages/e4/d0/1477ea50fc5a0d4b0b71d1d63d50770bdd794d90b43e37a7618e63ec9894/ruff-0.16.2-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:e0422abdf70070255fc4073ce9dfc814cc03db577013761ddd09bc1e4a9a4fbd", size = 11556038, upload-time = "2026-08-07T13:30:50.686Z" },
2755
- { url = "https://files.pythonhosted.org/packages/b8/76/a7776f32048d991e16d4fa8ff91790b877342d3596cc3ed04acdbf1aaedc/ruff-0.16.2-py3-none-win32.whl", hash = "sha256:bf3a63d78fb39f4bf5ac8ae52051c5520505301abe19ba4e204c453b3f09bb0b", size = 10872850, upload-time = "2026-08-07T13:30:53.471Z" },
2756
- { url = "https://files.pythonhosted.org/packages/00/0d/929c800d920e61397d82a01b60bffc68da3052c17d31de59efaad2e4ed75/ruff-0.16.2-py3-none-win_amd64.whl", hash = "sha256:bcabe2f6d0fc7819f1431793005af4e4de7371927d037345bf941252b195b9fa", size = 12023338, upload-time = "2026-08-07T13:30:56.193Z" },
2757
- { url = "https://files.pythonhosted.org/packages/5b/6c/93e26c22c5f78ff87363e07da49c84955affbeb1098bd1936bf3b3f293bf/ruff-0.16.2-py3-none-win_arm64.whl", hash = "sha256:d614e95cedf38a2053fd351c55b103ba30d017d61688fdbfd40ee0412852a99f", size = 11374065, upload-time = "2026-08-07T13:30:58.775Z" },
2737
+ version = "0.16.8"
2738
+ source = { registry = "https://pypi.org/simple" }
2739
+ sdist = { url = "https://files.pythonhosted.org/packages/ba/78/449cb84790bd5cc3823b2652ee405a4558856e5c4195aee3a16bf7b3eb5d/ruff-0.16.8.tar.gz", hash = "sha256:9247bf92b5f04d825c8639a4fe423ec2e4222acd9222e58412b0dab7e442798b", size = 4938814, upload-time = "2026-09-16T15:54:46.688Z" }
2740
+ wheels = [
2741
+ { url = "https://files.pythonhosted.org/packages/ac/25/6071aabc530e9be7e2c195e8fe3f7aea2735405b6cf447212832d7811831/ruff-0.16.8-py3-none-linux_armv6l.whl", hash = "sha256:6ffbd6d87383c1edf5f6fa890f10200950240d7c1a16052a19a09d3a2307dd38", size = 10048966, upload-time = "2026-09-16T15:53:57.605Z" },
2742
+ { url = "https://files.pythonhosted.org/packages/54/98/07f90ecbc74dd5fb5764f11f2bc774d6a7cffef92d2ff5f5b4e9e23c754e/ruff-0.16.8-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:42ed6b878ed61e3acca92f2730a17acff39286944ea82398544696366a6f925e", size = 10165498, upload-time = "2026-09-16T15:54:01.14Z" },
2743
+ { url = "https://files.pythonhosted.org/packages/fe/1f/e6a712e3b47cad4a40600134105ed193cb773f618a42eb7ba323cb812cc0/ruff-0.16.8-py3-none-macosx_11_0_arm64.whl", hash = "sha256:7ea781c7f2afba8c6a505ea0fb3f994020249e0c450635f5381286fea6b46170", size = 9830004, upload-time = "2026-09-16T15:54:03.998Z" },
2744
+ { url = "https://files.pythonhosted.org/packages/23/f2/311a08776d75d81c7676e20b6b020ae63cbe881fcdc7a8dd64e6e18bdd93/ruff-0.16.8-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8efeae3bbe414a5efefda11a792dfb51ef90ac48d50c4830de2f644caf3e8659", size = 9986558, upload-time = "2026-09-16T15:54:06.804Z" },
2745
+ { url = "https://files.pythonhosted.org/packages/f3/ed/37b6cb3d3ba8c73e68ae3eb1d502383beb5aa05a582bb7bb3a922f929f54/ruff-0.16.8-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:3a79b795469fef7fc6e908b218eed2eb17332afd85031db6480dc864560e69b2", size = 9877332, upload-time = "2026-09-16T15:54:09.552Z" },
2746
+ { url = "https://files.pythonhosted.org/packages/22/cc/40873a8f36ad084cc540d55fcca7077264d5b13b24659e9180c176fb2b08/ruff-0.16.8-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3fdc5563cdc50555e6fba39322850860e9267c1b3d12c26a74729d8604c3c812", size = 10507125, upload-time = "2026-09-16T15:54:12.152Z" },
2747
+ { url = "https://files.pythonhosted.org/packages/c3/e4/fc91a642b78ccbab6b9477720f3644ae7a10a9bcce69a934679cd64f62bc/ruff-0.16.8-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:34508983c70665578dab88f5223d8e6228307e1135398ca8bfc8b7e9501e282b", size = 11336694, upload-time = "2026-09-16T15:54:15.489Z" },
2748
+ { url = "https://files.pythonhosted.org/packages/c2/3d/bbd2a9a600a4e73dc3e7548a249c8d1671273464b55822c6fae50f602dff/ruff-0.16.8-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:644bb578569e0ffc575741232bd385dacdd6fbe123f1a729e7a225f54aa3957f", size = 10774448, upload-time = "2026-09-16T15:54:18.16Z" },
2749
+ { url = "https://files.pythonhosted.org/packages/1a/41/d83af9879a7b6e8bf5fe16b1da0b134049d2f5d3afac12defb0897cb84bd/ruff-0.16.8-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:15e7d226246961db9235098333caa13063906d3851136b84c2900b82f5daa1df", size = 10323796, upload-time = "2026-09-16T15:54:20.743Z" },
2750
+ { url = "https://files.pythonhosted.org/packages/f5/2c/cefd07bfe914b84943ea769ade8d607bd22750b965d3228eefd7cebd15d0/ruff-0.16.8-py3-none-manylinux_2_31_riscv64.whl", hash = "sha256:a2bf6bc3e9ebdd4449abc6f06cf64b98051a2c61cf94d2fe9596518c881f1a1e", size = 10514115, upload-time = "2026-09-16T15:54:23.497Z" },
2751
+ { url = "https://files.pythonhosted.org/packages/f3/9d/76a2e26c79a23be6e6e3664c57bec9e9fc8de155cfb9e4b67ea91b64f9d7/ruff-0.16.8-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:6ca111ba0849539165e9e59d2b442542f3c1e8060ebbdea82494f1ffbccb1e1f", size = 10072582, upload-time = "2026-09-16T15:54:26.185Z" },
2752
+ { url = "https://files.pythonhosted.org/packages/2e/d4/f42edddb39668af1a559ceafa3823aedd65633a48dc9768e775485faa2c1/ruff-0.16.8-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:359a1e5b495448ee1e91018064382ebc86f90e8aac2fed222c7d0e4e8df85fd2", size = 9879644, upload-time = "2026-09-16T15:54:29.278Z" },
2753
+ { url = "https://files.pythonhosted.org/packages/f8/d4/913e3195d95e0378786c6656945c865f534a3560e29139da4882aff630d1/ruff-0.16.8-py3-none-musllinux_1_2_i686.whl", hash = "sha256:59e8f5681349474110b24d62e93cfda6593f5fa3473446ca3705200cac1a08b9", size = 10231569, upload-time = "2026-09-16T15:54:32.036Z" },
2754
+ { url = "https://files.pythonhosted.org/packages/2b/c4/8aa6ea0bdcedbd1bf87397e2fc4ed8406448ea5842f8660bc6e5f163039d/ruff-0.16.8-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:efa3e7a16d1baaa79957888dfdf8be9ef2e44db81cb032af06d76632ab59e773", size = 10663666, upload-time = "2026-09-16T15:54:34.838Z" },
2755
+ { url = "https://files.pythonhosted.org/packages/3d/02/7f10ef4700bc223c30a3fdd10631a29830c45524b810a3c7ed947af64591/ruff-0.16.8-py3-none-win32.whl", hash = "sha256:55793ba85c69921e89be061426d91a78652d6e50317c962240922747a4eb713f", size = 10093472, upload-time = "2026-09-16T15:54:37.47Z" },
2756
+ { url = "https://files.pythonhosted.org/packages/1e/5d/a509c07d714b6da88f2c518b4637cf6f1d46b074be8f0f1e5fb9ff5126fe/ruff-0.16.8-py3-none-win_amd64.whl", hash = "sha256:a6b85621fd3c81e31fc5f5add09c9c078b430db3595ca632efafdec9e64ebfaa", size = 10586899, upload-time = "2026-09-16T15:54:40.488Z" },
2757
+ { url = "https://files.pythonhosted.org/packages/fe/a0/50787329e4f20bf9dc9f6230015d46ec69c51a97ace5bc202dae4755365d/ruff-0.16.8-py3-none-win_arm64.whl", hash = "sha256:d075e820af612102ce217f07cc93e69f9490b10ec13ea85fa87bd03d996cef8a", size = 10386316, upload-time = "2026-09-16T15:54:43.332Z" },
2758
2758
  ]
2759
2759
 
2760
2760
  [[package]]
@@ -1,131 +0,0 @@
1
- import asyncio
2
- import logging
3
- import threading
4
- import time
5
- from collections.abc import Callable
6
- from typing import Any
7
-
8
- import cv2
9
- from pyobs.modules.camera import BaseVideo
10
-
11
- log = logging.getLogger(__name__)
12
-
13
- # cv2's V4L2 backend calls are blocking and are made directly on the event loop thread (see
14
- # _run_blocking). If the camera has gone unresponsive, they can hang indefinitely, so they're
15
- # bounded with a timeout rather than let a single dead camera freeze the whole module.
16
- _SDK_CALL_TIMEOUT = 5.0
17
-
18
- # read() waits for the next frame, which can legitimately take a while depending on the camera's
19
- # own frame rate -- a more generous timeout than _SDK_CALL_TIMEOUT so normal operation never trips it.
20
- _FRAME_WAIT_TIMEOUT = 30.0
21
-
22
-
23
- class v4lCamera(BaseVideo):
24
- def __init__(self, device: int = 0, **kwargs: Any):
25
- BaseVideo.__init__(self, **kwargs)
26
-
27
- # store
28
- self._device = device
29
-
30
- # thread
31
- self.add_background_task(self._capture)
32
-
33
- @staticmethod
34
- async def _run_blocking(func: Callable[[], None], timeout: float = _SDK_CALL_TIMEOUT) -> bool:
35
- """Run a blocking cv2/V4L2 call in a daemon thread, so a hung call can't freeze the module.
36
-
37
- A plain executor isn't used here, since its worker threads are non-daemon and Python joins
38
- them on interpreter shutdown -- a hung call would then just move the freeze to process exit.
39
-
40
- Returns:
41
- True if func completed within timeout, False if it's still running in the background.
42
- """
43
- loop = asyncio.get_running_loop()
44
- future: asyncio.Future[None] = loop.create_future()
45
-
46
- def _finish() -> None:
47
- # wait_for cancels the future on timeout, so guard set_result to avoid an
48
- # InvalidStateError from the loop thread once the orphaned call finally ends.
49
- if not future.done():
50
- future.set_result(None)
51
-
52
- def _wrapper() -> None:
53
- try:
54
- func()
55
- finally:
56
- loop.call_soon_threadsafe(_finish)
57
-
58
- threading.Thread(target=_wrapper, daemon=True).start()
59
- try:
60
- await asyncio.wait_for(future, timeout=timeout)
61
- return True
62
- except TimeoutError:
63
- return False
64
-
65
- async def _open_camera(self) -> Any:
66
- """Open the V4L2 camera device, without blocking the event loop."""
67
- result: list[Any] = []
68
- lock = threading.Lock()
69
- timed_out = False
70
-
71
- def _open() -> None:
72
- camera = cv2.VideoCapture(self._device)
73
- with lock:
74
- if timed_out:
75
- # timed out while still opening; release the handle nobody will use
76
- camera.release()
77
- else:
78
- result.append(camera)
79
-
80
- if not await self._run_blocking(_open):
81
- with lock:
82
- timed_out = True
83
- if result:
84
- result.pop().release()
85
- raise TimeoutError(f"Timed out opening camera device after {_SDK_CALL_TIMEOUT}s.")
86
- return result[0]
87
-
88
- async def _read_frame(self, camera: Any) -> Any:
89
- """Read the next frame from the camera, without blocking the event loop.
90
-
91
- Returns:
92
- The next frame, or None if the read timed out.
93
- """
94
- result: list[Any] = []
95
-
96
- def _read() -> None:
97
- _, frame = camera.read()
98
- result.append(frame)
99
-
100
- if not await self._run_blocking(_read, timeout=_FRAME_WAIT_TIMEOUT):
101
- log.error("Timed out reading frame after %.1fs.", _FRAME_WAIT_TIMEOUT)
102
- return None
103
- return result[0]
104
-
105
- async def _capture(self) -> None:
106
- # open camera
107
- camera = await self._open_camera()
108
-
109
- # loop until the background task is cancelled on close
110
- last = time.time()
111
- try:
112
- while True:
113
- # read frame
114
- frame = await self._read_frame(camera)
115
- if frame is None:
116
- continue
117
-
118
- # if time since last image is too short, wait a little
119
- if time.time() - last < self._interval:
120
- await asyncio.sleep(0.01)
121
- continue
122
- last = time.time()
123
-
124
- # process it
125
- await self._set_image(frame)
126
- finally:
127
- # release camera
128
- camera.release()
129
-
130
-
131
- __all__ = ["v4lCamera"]
@@ -1,45 +0,0 @@
1
- """Unit tests for the non-hardware logic in v4lCamera: constructor state and the
2
- _run_blocking timeout wrapper.
3
-
4
- Opening the V4L2 device and reading frames is out of scope here.
5
- """
6
-
7
- import asyncio
8
- import threading
9
-
10
- import pytest
11
-
12
- from pyobs_v4l import v4lCamera
13
-
14
-
15
- def test_constructor_defaults() -> None:
16
- camera = v4lCamera()
17
- assert camera._device == 0
18
-
19
-
20
- def test_constructor_device() -> None:
21
- camera = v4lCamera(device=3)
22
- assert camera._device == 3
23
-
24
-
25
- @pytest.mark.asyncio
26
- async def test_run_blocking_runs_func_and_returns_true() -> None:
27
- ran: list[bool] = []
28
-
29
- def fast() -> None:
30
- ran.append(True)
31
-
32
- assert await v4lCamera._run_blocking(fast) is True
33
- assert ran == [True]
34
-
35
-
36
- @pytest.mark.asyncio
37
- async def test_run_blocking_times_out() -> None:
38
- done = threading.Event()
39
-
40
- def slow() -> None:
41
- done.wait()
42
-
43
- assert await v4lCamera._run_blocking(slow, timeout=0.01) is False
44
- done.set()
45
- await asyncio.sleep(0.05) # let the daemon thread drain before the loop closes
File without changes
File without changes
File without changes
File without changes