Skip to content

camera: Let exec() take the timeout for stopping the running script. - #30

Merged
iabdalkader merged 1 commit into
openmv:masterfrom
kwagyeman:fix/exec-stop-timeout
Nov 8, 2026
Merged

iabdalkader merged 1 commit into
openmv:masterfrom
kwagyeman:fix/exec-stop-timeout

Conversation

@kwagyeman

@kwagyeman kwagyeman commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

exec() stops a running script first, but calls stop() with the default timeout and gives the caller no way to change it. A script that takes longer than that to exit, e.g. a KeyboardInterrupt handler that cleans up, makes exec() raise TimeoutException.

Add timeout to exec() and pass it through to stop(). Default unchanged.

Tested on an N6 with a script that sleeps 2 s in its KeyboardInterrupt handler: exec(script) raises after 1 s as before, exec(script, timeout=6) runs the new script after 2.6 s.

While a KeyboardInterrupt handler is rare, Claude found this while testing a boot.py that takes 2 seconds or longer to finish - you'd hit this in the case of customizing boot.py.

@iabdalkader

Copy link
Copy Markdown
Member

I think the default stop() timeout should have been None, i.e., remove this?

timeout = self.timeout if timeout is None else timeout

There's nothing you can do to forcibly stop a script and run another one, if that script catchesKeyboardInterrupt and doesn't exit.

…eout.

stop() waits for the running script to exit for as long as it takes
unless a timeout is given, and exec() forwards its timeout to stop().
A dead link is still bounded by the transport timeout and resync.
@kwagyeman
kwagyeman force-pushed the fix/exec-stop-timeout branch from 500afc8 to d7f7621 Compare November 8, 2026 08:18
@kwagyeman

Copy link
Copy Markdown
Member Author

That works, it's safe too as the transport will break underneath if there's a comm issue.

@iabdalkader
iabdalkader merged commit 3c2ec0f into openmv:master Nov 8, 2026
2 checks passed
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