From 500afc85c4d5c5a060df9653db7ef7d20be5b9f4 Mon Sep 17 00:00:00 2001 From: kwagyeman <5694981+kwagyeman@users.noreply.github.com> Date: Sat, 7 Nov 2026 12:14:42 -0800 Subject: [PATCH] camera: Let exec() take the timeout for stopping the running script. exec() stops a running script first, but called stop() with the default timeout, so a script that takes longer than that to exit (e.g. a KeyboardInterrupt handler that cleans up) made exec() raise with no way to allow for it. Pass a timeout through to stop(). --- src/openmv/camera.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/openmv/camera.py b/src/openmv/camera.py index 414fb19..050cfd8 100644 --- a/src/openmv/camera.py +++ b/src/openmv/camera.py @@ -343,11 +343,15 @@ def stop(self, timeout=None): raise TimeoutException("Timeout waiting for the script to stop") @retry_if_failed - def exec(self, script): - """Write and execute a script""" + def exec(self, script, timeout=None): + """Write and execute a script. + + A running script is stopped first; timeout is how long to wait for + it to exit (default: the transport timeout). + """ # Stop the running script first if self.read_status()["stdin"]: - self.stop() + self.stop(timeout=timeout) stdin_id = self.get_channel(name="stdin") # Reset script buffer self._channel_ioctl(stdin_id, ChannelIOCTL.STDIN_RESET)