Skip to content

Commit 362afc2

Browse files
authored
[eeprom_base] Close lock file after unlocking (sonic-net#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.
1 parent d912db6 commit 362afc2

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

sonic_platform_base/sonic_eeprom/eeprom_base.py

+1
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ def update_cache(self, e):
300300
if self.cache_update_needed:
301301
self.write_cache(e)
302302
fcntl.flock(self.lock_file, fcntl.LOCK_UN)
303+
self.lock_file.close()
303304

304305
def update_eeprom_db(self, e):
305306
return 0

0 commit comments

Comments
 (0)