diff options
Diffstat (limited to 'bitbake/lib/bb/cache.py')
-rw-r--r-- | bitbake/lib/bb/cache.py | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/bitbake/lib/bb/cache.py b/bitbake/lib/bb/cache.py index 1c975b62e1..c92ba35641 100644 --- a/bitbake/lib/bb/cache.py +++ b/bitbake/lib/bb/cache.py | |||
@@ -738,8 +738,9 @@ class MultiProcessCache(object): | |||
738 | logger.debug(1, "Using cache in '%s'", self.cachefile) | 738 | logger.debug(1, "Using cache in '%s'", self.cachefile) |
739 | 739 | ||
740 | try: | 740 | try: |
741 | p = pickle.Unpickler(file(self.cachefile, "rb")) | 741 | with open(self.cachefile, "rb") as f: |
742 | data, version = p.load() | 742 | p = pickle.Unpickler(f) |
743 | data, version = p.load() | ||
743 | except: | 744 | except: |
744 | return | 745 | return |
745 | 746 | ||
@@ -779,8 +780,9 @@ class MultiProcessCache(object): | |||
779 | i = i + 1 | 780 | i = i + 1 |
780 | continue | 781 | continue |
781 | 782 | ||
782 | p = pickle.Pickler(file(self.cachefile + "-" + str(i), "wb"), -1) | 783 | with open(self.cachefile + "-" + str(i), "wb") as f: |
783 | p.dump([self.cachedata_extras, self.__class__.CACHE_VERSION]) | 784 | p = pickle.Pickler(f, -1) |
785 | p.dump([self.cachedata_extras, self.__class__.CACHE_VERSION]) | ||
784 | 786 | ||
785 | bb.utils.unlockfile(lf) | 787 | bb.utils.unlockfile(lf) |
786 | bb.utils.unlockfile(glf) | 788 | bb.utils.unlockfile(glf) |
@@ -798,8 +800,9 @@ class MultiProcessCache(object): | |||
798 | glf = bb.utils.lockfile(self.cachefile + ".lock") | 800 | glf = bb.utils.lockfile(self.cachefile + ".lock") |
799 | 801 | ||
800 | try: | 802 | try: |
801 | p = pickle.Unpickler(file(self.cachefile, "rb")) | 803 | with open(self.cachefile, "rb") as f: |
802 | data, version = p.load() | 804 | p = pickle.Unpickler(f) |
805 | data, version = p.load() | ||
803 | except (IOError, EOFError): | 806 | except (IOError, EOFError): |
804 | data, version = None, None | 807 | data, version = None, None |
805 | 808 | ||
@@ -809,8 +812,9 @@ class MultiProcessCache(object): | |||
809 | for f in [y for y in os.listdir(os.path.dirname(self.cachefile)) if y.startswith(os.path.basename(self.cachefile) + '-')]: | 812 | for f in [y for y in os.listdir(os.path.dirname(self.cachefile)) if y.startswith(os.path.basename(self.cachefile) + '-')]: |
810 | f = os.path.join(os.path.dirname(self.cachefile), f) | 813 | f = os.path.join(os.path.dirname(self.cachefile), f) |
811 | try: | 814 | try: |
812 | p = pickle.Unpickler(file(f, "rb")) | 815 | with open(f, "rb") as fd: |
813 | extradata, version = p.load() | 816 | p = pickle.Unpickler(fd) |
817 | extradata, version = p.load() | ||
814 | except (IOError, EOFError): | 818 | except (IOError, EOFError): |
815 | extradata, version = self.create_cachedata(), None | 819 | extradata, version = self.create_cachedata(), None |
816 | 820 | ||
@@ -822,8 +826,9 @@ class MultiProcessCache(object): | |||
822 | 826 | ||
823 | self.compress_keys(data) | 827 | self.compress_keys(data) |
824 | 828 | ||
825 | p = pickle.Pickler(file(self.cachefile, "wb"), -1) | 829 | with open(self.cachefile, "wb") as f: |
826 | p.dump([data, self.__class__.CACHE_VERSION]) | 830 | p = pickle.Pickler(f, -1) |
831 | p.dump([data, self.__class__.CACHE_VERSION]) | ||
827 | 832 | ||
828 | bb.utils.unlockfile(glf) | 833 | bb.utils.unlockfile(glf) |
829 | 834 | ||