From 68cf974c784630da0f4b5136c776beb9158d6cf5 Mon Sep 17 00:00:00 2001 From: Marcus Huewe Date: Tue, 15 Jan 2019 16:44:29 +0100 Subject: [PATCH] Do not mmap the ar archive There is really no need for a mmap here. Also, the comment in the docstr does not apply/is nonsense (there is no performance gain). --- osc/util/ar.py | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/osc/util/ar.py b/osc/util/ar.py index cdb52446..5d1b11d7 100644 --- a/osc/util/ar.py +++ b/osc/util/ar.py @@ -165,20 +165,9 @@ class Ar: self.__file.read(hdr.size)) def read(self): - """reads in the archive. It tries to use mmap due to performance reasons (in case of large files)""" + """reads in the archive.""" if not self.__file: - import mmap self.__file = open(self.filename, 'rb') - try: - if sys.platform[:3] != 'win': - self.__file = mmap.mmap(self.__file.fileno(), os.path.getsize(self.__file.name), prot=mmap.PROT_READ) - else: - self.__file = mmap.mmap(self.__file.fileno(), os.path.getsize(self.__file.name)) - except EnvironmentError as e: - if e.errno == 19 or ( hasattr(e, 'winerror') and e.winerror == 5 ): - print('cannot use mmap to read the file, falling back to the default io', file=sys.stderr) - else: - raise e else: self.__file.seek(0, os.SEEK_SET) self._init_datastructs()