Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

Commit e7c4056

Browse files
committed
nvdemux: Do not stop the monitor and retry after reboots
1 parent 52b2eb2 commit e7c4056

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/nvdemux/driver.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,16 @@ async def connect(self):
120120
# Use a short sleep to allow checking ready state
121121
await sleep(0.1)
122122

123-
# Get the current pts path from manager
123+
# Get the current pts path from manager (retry until timeout)
124124
manager = DemuxerManager.get_instance()
125+
pts_start = time.monotonic()
125126
pts_path = manager.get_pts_path(str(self.uuid))
126-
127-
if not pts_path:
128-
raise RuntimeError("Demuxer ready but no pts path available")
127+
while not pts_path:
128+
elapsed = time.monotonic() - pts_start
129+
if elapsed >= self.timeout:
130+
raise TimeoutError("Demuxer ready but no pts path available after retrying")
131+
await sleep(self.poll_interval)
132+
pts_path = manager.get_pts_path(str(self.uuid))
129133

130134
cps_info = f", cps: {self.cps}" if self.cps is not None else ""
131135
self.logger.info("Connecting to %s, baudrate: %d%s", pts_path, self.baudrate, cps_info)

packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/nvdemux/manager.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ def register_driver(
163163
# If target is already ready, notify immediately
164164
notify_args = self._get_ready_callback(target, callback)
165165

166-
# Start monitor thread if this is the first driver
167-
if len(self._drivers) == 1:
166+
# Start monitor thread only once
167+
if not self._monitor_thread or not self._monitor_thread.is_alive():
168168
self._start_monitor()
169169

170170
if notify_args:
@@ -186,9 +186,7 @@ def unregister_driver(self, driver_id: str) -> None:
186186
del self._drivers[driver_id]
187187
logger.info("Unregistered driver %s (target: %s)", driver_id, target)
188188

189-
# Stop monitor thread if this was the last driver
190-
if not self._drivers:
191-
self._stop_monitor()
189+
# Keep monitor running even if no drivers remain
192190

193191
def get_pts_path(self, driver_id: str) -> str | None:
194192
"""Get the pts path for a registered driver.

packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/nvdemux/manager_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,10 +426,10 @@ def test_reference_counting():
426426
time.sleep(0.2)
427427
assert not mock_proc._terminated
428428

429-
# Unregister second driver - process should stop
429+
# Unregister second driver - process should still continue (monitor stays running)
430430
manager.unregister_driver("driver2")
431431
time.sleep(0.2)
432-
assert mock_proc._terminated
432+
assert not mock_proc._terminated
433433

434434
# Cleanup
435435
DemuxerManager.reset_instance()

0 commit comments

Comments
 (0)