py: cam.py: Exit on exception

Catch exceptions in the event_handler, as they would get ignored
otherwise. Print the exception and return False so that the main loop
exits.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Tomi Valkeinen 2022-05-18 16:13:19 +03:00 committed by Laurent Pinchart
parent 7ac7e0e119
commit 1384cedf50

View file

@ -11,6 +11,7 @@ import binascii
import libcamera as libcam
import os
import sys
import traceback
class CustomAction(argparse.Action):
@ -286,6 +287,7 @@ def capture_start(contexts):
# Called from renderer when there is a libcamera event
def event_handler(state):
try:
cm = state['cm']
contexts = state['contexts']
@ -299,6 +301,9 @@ def event_handler(state):
running = any(ctx['reqs-completed'] < ctx['opt-capture'] for ctx in contexts)
return running
except Exception as e:
traceback.print_exc()
return False
def request_handler(state, ctx, req):