mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-20 00:38:38 +02:00
Updated commit message (now includes the test fix):
Fix camera button permissions & ffmpeg process leak (#550) Camera button on printer card was clickable without camera:view permission. ffmpeg processes (~240MB each) accumulated after closing camera streams because: (1) stop endpoint called terminate() without wait()/kill(), (2) HTTP disconnect detection only ran between frames so was blocked when the generator was stuck on stdout read, and (3) no mechanism caught processes orphaned by generator abandonment or app restarts. - Add camera:view permission check + tooltip to camera button - Fix stop endpoint: terminate() → wait(2s) → kill() → wait() - Add background disconnect monitor (polls every 2s, kills ffmpeg directly on disconnect) - Add periodic /proc scan (every 60s) that SIGKILLs any ffmpeg with rtsps://bblp: not in an active stream - Add noCamera i18n key to all 6 locales - Fix camera API test mocks for async wait() and pid attribute
This commit is contained in:
@@ -59,10 +59,12 @@ class TestCameraAPI:
|
||||
"""Verify stop terminates active streams for the printer."""
|
||||
printer = await printer_factory()
|
||||
|
||||
# Mock an active stream
|
||||
# Mock an active stream — wait() must be AsyncMock since it's awaited
|
||||
mock_process = MagicMock()
|
||||
mock_process.returncode = None
|
||||
mock_process.pid = 99999
|
||||
mock_process.terminate = MagicMock()
|
||||
mock_process.wait = AsyncMock()
|
||||
|
||||
with patch("backend.app.api.routes.camera._active_streams", {f"{printer.id}-abc123": mock_process}):
|
||||
response = await async_client.post(f"/api/v1/printers/{printer.id}/camera/stop")
|
||||
@@ -78,14 +80,18 @@ class TestCameraAPI:
|
||||
printer1 = await printer_factory(name="Printer 1")
|
||||
printer2 = await printer_factory(name="Printer 2")
|
||||
|
||||
# Mock active streams for both printers
|
||||
# Mock active streams for both printers — wait() must be AsyncMock since it's awaited
|
||||
mock_process1 = MagicMock()
|
||||
mock_process1.returncode = None
|
||||
mock_process1.pid = 99998
|
||||
mock_process1.terminate = MagicMock()
|
||||
mock_process1.wait = AsyncMock()
|
||||
|
||||
mock_process2 = MagicMock()
|
||||
mock_process2.returncode = None
|
||||
mock_process2.pid = 99997
|
||||
mock_process2.terminate = MagicMock()
|
||||
mock_process2.wait = AsyncMock()
|
||||
|
||||
active_streams = {
|
||||
f"{printer1.id}-abc123": mock_process1,
|
||||
|
||||
Reference in New Issue
Block a user