From patchwork Tue May 17 14:33:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 15931 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id D8C94C326F for ; Tue, 17 May 2022 14:33:59 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0D1B865670; Tue, 17 May 2022 16:33:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652798039; bh=NI44KOnwRz0zUZLq5P8HPPG0KXibhhJuHsRNwPXF7l8=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=wCKOOmsXCv/VmR/KK7unh9hwjwBJEPFMQnZqxB7QJRGZdgSZEgnzAn3Nlw4veJoZq LN/uC6qTTo/Umy683yHJmVi/NOcPjELKYnLupiY5hY9nZsjCD6o+9FfEcHsKj1fNZu F+xohl7IujTXaKUUYO4mi7BoP7lAgXUbU3+zJAfl/0quca5Uf9oN7W0m+QJ3Bejauw 36UKDFWrz3QUTm38DEFFkTdGEaqNlOrj81h4+01zzQGctZZvKYtWfQHps2uAPqcDa2 CvNlM+NJVwATfzSaC5rl8Egs1p+gXwUebp5ZDtqmT6eJHmd0RfwF6hF2NWEdnyDhvY /KihUWtmZCbDA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 300C76565E for ; Tue, 17 May 2022 16:33:55 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="mxTHjsw6"; dkim-atps=neutral Received: from deskari.lan (91-156-85-209.elisa-laajakaista.fi [91.156.85.209]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9A6BA4A8; Tue, 17 May 2022 16:33:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652798035; bh=NI44KOnwRz0zUZLq5P8HPPG0KXibhhJuHsRNwPXF7l8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mxTHjsw6eAniiQjETS864vMFP7iz6o+ncV3PAJaEgTQ6IENbgoJjEimmwMkibA+Jv L2REMtdoDChefJdrZFk/dtjABusKzi9MRshmXuED0ZILeMdJedKmhKsP8oKyZFD63j 4H4Yy2Pgazp0/9VlCxOTLTPfKHWcKsK1cbwh0xKQ= To: libcamera-devel@lists.libcamera.org, David Plowman , Kieran Bingham , Laurent Pinchart , Jacopo Mondi Date: Tue, 17 May 2022 17:33:19 +0300 Message-Id: <20220517143325.71784-8-tomi.valkeinen@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220517143325.71784-1-tomi.valkeinen@ideasonboard.com> References: <20220517143325.71784-1-tomi.valkeinen@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 07/13] py: cam.py: exit on exception X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tomi Valkeinen via libcamera-devel From: Tomi Valkeinen Reply-To: Tomi Valkeinen Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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 Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- src/py/cam/cam.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/py/cam/cam.py b/src/py/cam/cam.py index 012b191c..c7da97d7 100755 --- a/src/py/cam/cam.py +++ b/src/py/cam/cam.py @@ -11,6 +11,7 @@ import binascii import libcamera as libcam import os import sys +import traceback class CustomAction(argparse.Action): @@ -286,19 +287,23 @@ def capture_start(contexts): # Called from renderer when there is a libcamera event def event_handler(state): - cm = state['cm'] - contexts = state['contexts'] + try: + 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: - ctx = next(ctx for ctx in contexts if ctx['idx'] == req.cookie) - request_handler(state, ctx, req) + for req in reqs: + ctx = next(ctx for ctx in contexts if ctx['idx'] == req.cookie) + request_handler(state, ctx, req) - running = any(ctx['reqs-completed'] < ctx['opt-capture'] for ctx in contexts) - return running + 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):