From 56449dc03795002b588feb7f0a99ba5e42f1ad09 Mon Sep 17 00:00:00 2001
From: gifrerenom <lluis.gifre@cttc.es>
Date: Tue, 24 Dec 2024 08:53:44 +0000
Subject: [PATCH] Device - gNMI OpenConfig Driver:

- Refining code
---
 .../gnmi_openconfig/handlers/Interface.py     | 32 ++++++++++++++++---
 1 file changed, 27 insertions(+), 5 deletions(-)

diff --git a/src/device/service/drivers/gnmi_openconfig/handlers/Interface.py b/src/device/service/drivers/gnmi_openconfig/handlers/Interface.py
index cb913d907..c471faf2e 100644
--- a/src/device/service/drivers/gnmi_openconfig/handlers/Interface.py
+++ b/src/device/service/drivers/gnmi_openconfig/handlers/Interface.py
@@ -92,12 +92,34 @@ class InterfaceHandler(_Handler):
             LOGGER.warning('Getting...')
             try:
                 obj = objects_to_free.get_nowait()
-                LOGGER.warning('Releasing: {:s}'.format(str(obj)))
-                if obj is None: continue
-                LOGGER.warning('Releasing: {:s} => {:s}'.format(
-                    str(obj.path()), str(obj.print_mem('json'))
-                ))
+                if obj is None:
+                    LOGGER.warning('Item is None')
+                    continue
+
+                try:
+                    type_obj = type(obj)
+                    LOGGER.warning('Releasing[type]: {:s}'.format(str(type_obj)))
+                except:
+                    LOGGER.exception('Releasing[type]: <failed>')
+
+                try:
+                    str_obj = str(obj)
+                    if str_obj is not None:
+                        LOGGER.warning('Releasing[str]: {:s}'.format(str_obj))
+                except:
+                    LOGGER.exception('Releasing[str]: <failed>')
+
+                try:
+                    repr_obj = repr(obj)
+                    if repr_obj is not None:
+                        LOGGER.warning('Releasing[repr]: {:s}'.format(str(repr_obj)))
+                except:
+                    LOGGER.exception('Releasing[repr]: <failed>')
+
                 try:
+                    LOGGER.warning('Releasing: {:s} => {:s}'.format(
+                        str(obj.path()), str(obj.print_mem('json'))
+                    ))
                     LOGGER.warning('Freeing...')
                     obj.free()
                     LOGGER.warning('Free done')
-- 
GitLab