From 6ebab7cf6c3cf819d5fced2b43903def1593ea42 Mon Sep 17 00:00:00 2001 From: Cristhian Garcia Date: Tue, 15 Oct 2024 13:26:53 -0500 Subject: [PATCH] refactor: define response outside try-except --- event_routing_backends/utils/xapi_lrs_client.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/event_routing_backends/utils/xapi_lrs_client.py b/event_routing_backends/utils/xapi_lrs_client.py index 8761dece..9b341f78 100644 --- a/event_routing_backends/utils/xapi_lrs_client.py +++ b/event_routing_backends/utils/xapi_lrs_client.py @@ -72,11 +72,14 @@ def bulk_send(self, statement_data): requests.Response object """ logger.debug('Sending {} xAPI statements to {}'.format(len(statement_data), self.URL)) + response = None try: response = self.lrs_client.save_statements(statement_data) - except JSONDecodeError as e: + except JSONDecodeError: logger.warning(f"Events already in LRS: {response.request.content}") + + if not response: return if not response.success: