Use with statement to auto-close tarfile

This commit is contained in:
Marshall Scorcio
2020-04-25 22:00:32 -07:00
parent ca938960f4
commit 0366a4c83d

View File

@@ -105,7 +105,6 @@ class GithubModelProvider(ModelProvider):
if compute_file_checksum(archive.name) != self.checksum(name):
raise IOError('Downloaded file is corrupted, please retry')
get_logger().info('Extracting downloaded %s archive', name)
tar = tarfile.open(name=archive.name)
tar.extractall(path=path)
tar.close()
with tarfile.open(name=archive.name) as tar:
tar.extractall(path=path)
get_logger().info('%s model file(s) extracted', name)