Skip to content

Commit

Permalink
[eeprom_base] Close lock file after unlocking (sonic-net#149)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jleveque authored Nov 25, 2020
1 parent d912db6 commit 362afc2
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions sonic_platform_base/sonic_eeprom/eeprom_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 362afc2

Please sign in to comment.