1
0
Fork 0
mirror of https://github.com/maziggy/bambuddy.git synced 2026-05-09 08:25:54 +02:00

[GH-ISSUE #605] [Bug]: Windows Portable server cleanly shuts down exactly 60 seconds after UI opens (ffmpeg cleanup triggers CTRL_C_EVENT) #389

Closed
opened 2026-05-07 00:09:33 +02:00 by BreizhHardware · 1 comment

Originally created by @Reactantvr on GitHub (Mar 4, 2026).
Original GitHub issue: https://github.com/maziggy/bambuddy/issues/605

Originally assigned to: @maziggy on GitHub.

Bug Description

Environment:

  • OS: Windows 10
  • Version: v0.2.1.1 (Standalone / Portable version)

Description:
When running the Windows portable version of Bambuddy, the backend server initiates a graceful, unprompted shutdown exactly 60 seconds after opening the web UI.

The logs do not show a crash/traceback; instead, they show a standard termination signal being received right as the camera stream cleanup task is triggered:

INFO:     Shutting down
INFO:     connection closed
INFO:     Waiting for connections to close. (CTRL+C to force quit)
WARNING   [backend.app.api.routes.camera] Camera stream ended (no more data)
INFO      [backend.app.api.routes.camera] Terminating ffmpeg process for stream 1-d1449f59
...
INFO:     Finished server process

Root Cause & Diagnosis:
The issue stems from how Windows handles process termination compared to Linux.
When the UI is opened, ffmpeg is spawned to handle the camera stream. Exactly 60 seconds later, _camera_cleanup_loop() fires and attempts to clean up orphaned ffmpeg streams.
When Python attempts to .terminate() or .kill() the ffmpeg subprocess on Windows, the OS broadcasts a CTRL_C_EVENT to the entire process group. Uvicorn receives this signal, assumes the user pressed Ctrl+C in the console, and dutifully initiates a graceful shutdown of the entire Bambuddy backend.

Confirmed Workaround:
I tested this by modifying backend\app\main.py and adding a return to the top of the _camera_cleanup_loop (around line 2233) to prevent the cleanup from running.

async def _camera_cleanup_loop():
    return # Added this to bypass
    from backend.app.api.routes.camera import cleanup_orphaned_streams

With this change, the server survives past 60 seconds and remains stable indefinitely, confirming the cleanup task is the culprit.

Expected Behavior

The backend server should continue running indefinitely while the web UI is open. The background _camera_cleanup_loop() should quietly terminate orphaned ffmpeg processes without broadcasting a CTRL_C_EVENT to the parent Uvicorn process group that causes the app to quit.

Steps to Reproduce

  1. Launch the Bambuddy v0.2.1.1 standalone/portable backend natively on Windows.
  2. Bambuddy web UI in a browser is already open along with single camera stream.
  3. Leave the UI open and wait exactly 60 seconds.
  4. Observe the console output: the server intercepts a termination signal, successfully stops the camera stream, and cleanly shuts itself down.

Printer Model

H2C

Bambuddy Version

0.2.1.1

Printer Firmware Version

01.01.00.00

Installation Method

Manual (git clone)

Operating System

Windows

Relevant Logs / Support Package


Screenshots

No response

Additional Context

No response

Checklist

  • I have searched existing issues to ensure this bug hasn't already been reported
  • I am using the latest version of Bambuddy
  • My printer is set to LAN Only mode
  • My printer has Developer Mode enabled
Originally created by @Reactantvr on GitHub (Mar 4, 2026). Original GitHub issue: https://github.com/maziggy/bambuddy/issues/605 Originally assigned to: @maziggy on GitHub. ### Bug Description **Environment:** * **OS:** Windows 10 * **Version:** v0.2.1.1 (Standalone / Portable version) **Description:** When running the Windows portable version of Bambuddy, the backend server initiates a graceful, unprompted shutdown exactly 60 seconds after opening the web UI. The logs do not show a crash/traceback; instead, they show a standard termination signal being received right as the camera stream cleanup task is triggered: ```text INFO: Shutting down INFO: connection closed INFO: Waiting for connections to close. (CTRL+C to force quit) WARNING [backend.app.api.routes.camera] Camera stream ended (no more data) INFO [backend.app.api.routes.camera] Terminating ffmpeg process for stream 1-d1449f59 ... INFO: Finished server process ``` **Root Cause & Diagnosis:** The issue stems from how Windows handles process termination compared to Linux. When the UI is opened, ffmpeg is spawned to handle the camera stream. Exactly 60 seconds later, `_camera_cleanup_loop()` fires and attempts to clean up orphaned ffmpeg streams. When Python attempts to `.terminate()` or `.kill()` the ffmpeg subprocess on Windows, the OS broadcasts a `CTRL_C_EVENT` to the entire process group. Uvicorn receives this signal, assumes the user pressed Ctrl+C in the console, and dutifully initiates a graceful shutdown of the entire Bambuddy backend. **Confirmed Workaround:** I tested this by modifying `backend\app\main.py` and adding a `return` to the top of the `_camera_cleanup_loop` (around line 2233) to prevent the cleanup from running. ```python async def _camera_cleanup_loop(): return # Added this to bypass from backend.app.api.routes.camera import cleanup_orphaned_streams ``` With this change, the server survives past 60 seconds and remains stable indefinitely, confirming the cleanup task is the culprit. ### Expected Behavior The backend server should continue running indefinitely while the web UI is open. The background `_camera_cleanup_loop()` should quietly terminate orphaned `ffmpeg` processes without broadcasting a `CTRL_C_EVENT` to the parent Uvicorn process group that causes the app to quit. ### Steps to Reproduce 1. Launch the Bambuddy v0.2.1.1 standalone/portable backend natively on Windows. 2. Bambuddy web UI in a browser is already open along with single camera stream. 3. Leave the UI open and wait exactly 60 seconds. 4. Observe the console output: the server intercepts a termination signal, successfully stops the camera stream, and cleanly shuts itself down. ### Printer Model H2C ### Bambuddy Version 0.2.1.1 ### Printer Firmware Version 01.01.00.00 ### Installation Method Manual (git clone) ### Operating System Windows ### Relevant Logs / Support Package ```shell ``` ### Screenshots _No response_ ### Additional Context _No response_ ### Checklist - [x] I have searched existing issues to ensure this bug hasn't already been reported - [x] I am using the latest version of Bambuddy - [x] My printer is set to LAN Only mode - [x] My printer has Developer Mode enabled
BreizhHardware 2026-05-07 00:09:33 +02:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@maziggy commented on GitHub (Mar 4, 2026):

Fixed in branch 0.2.2b2.


If you find Bambuddy useful, please consider giving it a on GitHub — it helps others discover the project!

<!-- gh-comment-id:3997887773 --> @maziggy commented on GitHub (Mar 4, 2026): Fixed in branch 0.2.2b2. ----- If you find Bambuddy useful, please consider giving it a ⭐ on [GitHub](https://github.com/bambuman/bambuddy) — it helps others discover the project!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/bambuddy-maziggy-1#389
No description provided.