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:
parent
7ac7e0e119
commit
1384cedf50
1 changed files with 14 additions and 9 deletions
|
@ -11,6 +11,7 @@ import binascii
|
||||||
import libcamera as libcam
|
import libcamera as libcam
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import traceback
|
||||||
|
|
||||||
|
|
||||||
class CustomAction(argparse.Action):
|
class CustomAction(argparse.Action):
|
||||||
|
@ -286,19 +287,23 @@ def capture_start(contexts):
|
||||||
|
|
||||||
# Called from renderer when there is a libcamera event
|
# Called from renderer when there is a libcamera event
|
||||||
def event_handler(state):
|
def event_handler(state):
|
||||||
cm = state['cm']
|
try:
|
||||||
contexts = state['contexts']
|
cm = state['cm']
|
||||||
|
contexts = state['contexts']
|
||||||
|
|
||||||
os.read(cm.efd, 8)
|
os.read(cm.efd, 8)
|
||||||
|
|
||||||
reqs = cm.get_ready_requests()
|
reqs = cm.get_ready_requests()
|
||||||
|
|
||||||
for req in reqs:
|
for req in reqs:
|
||||||
ctx = next(ctx for ctx in contexts if ctx['idx'] == req.cookie)
|
ctx = next(ctx for ctx in contexts if ctx['idx'] == req.cookie)
|
||||||
request_handler(state, ctx, req)
|
request_handler(state, ctx, req)
|
||||||
|
|
||||||
running = any(ctx['reqs-completed'] < ctx['opt-capture'] for ctx in contexts)
|
running = any(ctx['reqs-completed'] < ctx['opt-capture'] for ctx in contexts)
|
||||||
return running
|
return running
|
||||||
|
except Exception as e:
|
||||||
|
traceback.print_exc()
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def request_handler(state, ctx, req):
|
def request_handler(state, ctx, req):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue