Skip to content

ustreamer: video streaming - #872

Merged
mangelajo merged 1 commit into
jumpstarter-dev:mainfrom
bennyz:video-stream
Jul 13, 2026
Merged

ustreamer: video streaming#872
mangelajo merged 1 commit into
jumpstarter-dev:mainfrom
bennyz:video-stream

Conversation

@bennyz

@bennyz bennyz commented Jul 9, 2026

Copy link
Copy Markdown
Member
$ j video
Usage: j video [OPTIONS] COMMAND [ARGS]...

  Video capture and streaming

Options:
  --help  Show this message and exit.

Commands:
  snapshot  Save a single snapshot to file
  state     Show video source state
  stream    Start local MJPEG streaming server

$ j video stream
Video stream available at: http://127.0.0.1:59172
Snapshot endpoint: http://127.0.0.1:59172/snapshot
Press Ctrl+C to stop.

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 69a211c2-af2a-402e-b27f-059aee29b072

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
python/packages/jumpstarter-driver-ustreamer/jumpstarter_driver_ustreamer/driver_test.py (1)

22-27: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert the actual prctl contract, not just callability.

This test would pass even if the hook used the wrong signal/option or stopped calling prctl. Patch _IS_LINUX and ctypes.CDLL so both platform branches and the Linux call contract are deterministic.

Suggested test expansion
+import signal
@@
 def test_get_preexec_fn_linux():
-    if not sys.platform.startswith("linux"):
+    if not sys.platform.startswith("linux"):
         assert _get_preexec_fn() is None
     else:
         assert callable(_get_preexec_fn())
+
+
+def test_get_preexec_fn_non_linux():
+    with patch("jumpstarter_driver_ustreamer.driver._IS_LINUX", False):
+        assert _get_preexec_fn() is None
+
+
+def test_get_preexec_fn_sets_pdeathsig_on_linux():
+    with (
+        patch("jumpstarter_driver_ustreamer.driver._IS_LINUX", True),
+        patch("jumpstarter_driver_ustreamer.driver.ctypes.CDLL") as mock_cdll,
+    ):
+        libc = mock_cdll.return_value
+        libc.prctl.return_value = 0
+
+        preexec_fn = _get_preexec_fn()
+        assert callable(preexec_fn)
+        preexec_fn()
+
+        libc.prctl.assert_called_once_with(1, signal.SIGTERM, 0, 0, 0)

As per coding guidelines, **/jumpstarter-driver-*/jumpstarter_driver_*/*_test.py: “Add comprehensive tests in driver_test.py file within the driver package.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@python/packages/jumpstarter-driver-ustreamer/jumpstarter_driver_ustreamer/driver_test.py`
around lines 22 - 27, The `_get_preexec_fn` test only checks callability, so it
can miss regressions in the Linux `prctl` setup. Update
`test_get_preexec_fn_linux` in `driver_test.py` to deterministically cover both
branches by patching `_IS_LINUX`, and mock `ctypes.CDLL` so you can assert the
Linux path actually calls `prctl` with the expected option and signal. Keep the
non-Linux branch asserting `None`, and make the Linux branch verify the returned
hook invokes `prctl` rather than only being callable.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@python/packages/jumpstarter-driver-ustreamer/jumpstarter_driver_ustreamer/client.py`:
- Around line 44-70: The _run_server helper is catching all BaseException
failures and masking real startup errors with the generic stopping message.
Update the exception handling around client.portal.call(serve) to catch only
KeyboardInterrupt, and let other exceptions from serve(), runner.setup(), or
site.start() propagate so actual failures remain visible; keep the cleanup in
the finally block via runner.cleanup.
- Around line 50-54: Use the public TCPSite API instead of reaching into aiohttp
internals when building the URL in the client startup flow. In the section that
starts the site and computes actual_port in client.py, replace the direct use of
site._server.sockets[0] with site.port after await site.start(), and keep the
url construction based on that value.

In
`@python/packages/jumpstarter-driver-ustreamer/jumpstarter_driver_ustreamer/driver.py`:
- Around line 46-56: Keep _get_preexec_fn() minimal by removing libc loading and
logger.warning calls from set_pdeathsig; that forked-child setup should only
perform the prctl(PR_SET_PDEATHSIG, signal.SIGTERM, ...) call and avoid any
logging or other risky work before exec. Change set_pdeathsig to raise an
exception on failure instead of swallowing errors, and handle/report the failure
in the parent side where the subprocess is created so the child path stays safe
and simple.

---

Nitpick comments:
In
`@python/packages/jumpstarter-driver-ustreamer/jumpstarter_driver_ustreamer/driver_test.py`:
- Around line 22-27: The `_get_preexec_fn` test only checks callability, so it
can miss regressions in the Linux `prctl` setup. Update
`test_get_preexec_fn_linux` in `driver_test.py` to deterministically cover both
branches by patching `_IS_LINUX`, and mock `ctypes.CDLL` so you can assert the
Linux path actually calls `prctl` with the expected option and signal. Keep the
non-Linux branch asserting `None`, and make the Linux branch verify the returned
hook invokes `prctl` rather than only being callable.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f9e07d8f-a7b9-439e-9bd0-14cc15dae188

📥 Commits

Reviewing files that changed from the base of the PR and between d46e91a and e2af656.

📒 Files selected for processing (3)
  • python/packages/jumpstarter-driver-ustreamer/jumpstarter_driver_ustreamer/client.py
  • python/packages/jumpstarter-driver-ustreamer/jumpstarter_driver_ustreamer/driver.py
  • python/packages/jumpstarter-driver-ustreamer/jumpstarter_driver_ustreamer/driver_test.py

@bennyz
bennyz force-pushed the video-stream branch 6 times, most recently from e5c4b02 to f12e774 Compare July 10, 2026 18:10
j video
Usage: j video [OPTIONS] COMMAND [ARGS]...

  Video capture and streaming

Options:
  --help  Show this message and exit.

Commands:
  snapshot  Save a single snapshot to file
  state     Show video source state
  stream    Start local MJPEG streaming server

Signed-off-by: Benny Zlotnik <bzlotnik@redhat.com>
Assisted-by: grok-4.5
@bennyz
bennyz marked this pull request as ready for review July 10, 2026 18:10
@bennyz
bennyz requested a review from mangelajo July 12, 2026 07:57
@mangelajo
mangelajo added this pull request to the merge queue Jul 13, 2026
Merged via the queue into jumpstarter-dev:main with commit a395292 Jul 13, 2026
24 checks passed
@bennyz
bennyz deleted the video-stream branch July 21, 2026 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants