From baa0561ccc5aeb65745f2eac6a38df4fe6b3d864 Mon Sep 17 00:00:00 2001 From: Lars Kiesow Date: Thu, 18 Jun 2020 02:04:51 +0200 Subject: [PATCH] Make safe_start_capture actually safe The method safe_start_capture would still throw an exception if the agent state could not be set (e.g. due to a network error) which could cause the capture service to fail. --- pyca/capture.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pyca/capture.py b/pyca/capture.py index 633ee48e..72449c76 100644 --- a/pyca/capture.py +++ b/pyca/capture.py @@ -89,12 +89,14 @@ def safe_start_capture(event): try: start_capture(event) except Exception: - logger.error('Recording failed') - logger.error(traceback.format_exc()) - # Update state - recording_state(event.uid, 'capture_error') - update_event_status(event, Status.FAILED_RECORDING) - set_service_status_immediate(Service.CAPTURE, ServiceStatus.IDLE) + logger.exception('Recording failed') + # Update current status in Opencast + try: + set_service_status_immediate(Service.CAPTURE, ServiceStatus.IDLE) + recording_state(event.uid, 'capture_error') + update_event_status(event, Status.FAILED_RECORDING) + except Exception: + logger.exception('Could not update recording status') def recording_command(event):