Skip to content

Commit

Permalink
Merge pull request sonic-net#18 from yxieca/no_buffering
Browse files Browse the repository at this point in the history
[sfp_util] open eeprom files with buffering disabled
  • Loading branch information
yxieca authored Dec 4, 2018
2 parents b8470c5 + c799a5e commit 0d1622a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions sonic_sfp/sfputilbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,9 @@ def _sfp_eeprom_present(self, sysfs_sfp_i2c_client_eeprompath, offset):
return False
else:
try:
sysfsfile = open(sysfs_sfp_i2c_client_eeprompath, "rb")
sysfsfile.seek(offset)
sysfsfile.read(1)
with open(sysfs_sfp_i2c_client_eeprompath, mode="rb", buffering=0) as sysfsfile:
sysfsfile.seek(offset)
sysfsfile.read(1)
except IOError:
return False
except:
Expand Down Expand Up @@ -275,7 +275,7 @@ def _read_eeprom_devid(self, port_num, devid, offset, num_bytes = 256):
return None

try:
sysfsfile_eeprom = open(sysfs_sfp_i2c_client_eeprom_path, "rb")
sysfsfile_eeprom = open(sysfs_sfp_i2c_client_eeprom_path, mode="rb", buffering=0)
except IOError:
print("Error: reading sysfs file %s" % sysfs_sfp_i2c_client_eeprom_path)
return None
Expand Down Expand Up @@ -646,7 +646,7 @@ def get_transceiver_info_dict(self, port_num):
return None

try:
sysfsfile_eeprom = open(file_path, "rb")
sysfsfile_eeprom = open(file_path, mode="rb", buffering=0)
except IOError:
print("Error: reading sysfs file %s" % file_path)
return None
Expand Down Expand Up @@ -711,7 +711,7 @@ def get_transceiver_dom_info_dict(self, port_num):
return None

try:
sysfsfile_eeprom = open(file_path, "rb")
sysfsfile_eeprom = open(file_path, mode="rb", buffering=0)
except IOError:
print("Error: reading sysfs file %s" % file_path)
return None
Expand Down Expand Up @@ -807,7 +807,7 @@ def get_transceiver_dom_info_dict(self, port_num):
return None

try:
sysfsfile_eeprom = open(file_path, "rb")
sysfsfile_eeprom = open(file_path, mode="rb", buffering=0)
except IOError:
print("Error: reading sysfs file %s" % file_path)
return None
Expand Down

0 comments on commit 0d1622a

Please sign in to comment.