From 362afc269f94880a65edf47fef41c442d266e25b Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Wed, 25 Nov 2020 10:18:21 -0800 Subject: [PATCH] [eeprom_base] Close lock file after unlocking (#149) Close EEPROM lock file after unlocking. Python 3 now outputs warnings such as the following to stderr if a file descriptor is left open: ``` /usr/local/bin/decode-syseeprom:171 : ResourceWarning : unclosed file <_io.TextIOWrapper name='/var/run/hw-management/eeprom/vpd_info' mode='r' encoding='UTF-8'> ``` With this change, the above warning is no longer displayed. --- sonic_platform_base/sonic_eeprom/eeprom_base.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sonic_platform_base/sonic_eeprom/eeprom_base.py b/sonic_platform_base/sonic_eeprom/eeprom_base.py index d505267072..7904f1e2a1 100644 --- a/sonic_platform_base/sonic_eeprom/eeprom_base.py +++ b/sonic_platform_base/sonic_eeprom/eeprom_base.py @@ -300,6 +300,7 @@ def update_cache(self, e): if self.cache_update_needed: self.write_cache(e) fcntl.flock(self.lock_file, fcntl.LOCK_UN) + self.lock_file.close() def update_eeprom_db(self, e): return 0