Use cPickle instead of pickle

This commit is contained in:
Gregory Soutade 2017-05-07 16:55:05 +02:00
parent 906fd5be11
commit 3ce35b7b47

View File

@ -24,7 +24,7 @@ import shutil
import sys import sys
import re import re
import time import time
import pickle import cPickle
import gzip import gzip
import importlib import importlib
import argparse import argparse
@ -248,7 +248,7 @@ class IWLA(object):
os.makedirs(base) os.makedirs(base)
with open(filename + '.tmp', 'wb+') as f, self._openDB(filename, 'w') as fzip: with open(filename + '.tmp', 'wb+') as f, self._openDB(filename, 'w') as fzip:
pickle.dump(obj, f) cPickle.dump(obj, f)
os.fsync(f) os.fsync(f)
f.seek(0) f.seek(0)
fzip.write(f.read()) fzip.write(f.read())
@ -258,9 +258,10 @@ class IWLA(object):
if not os.path.exists(filename): if not os.path.exists(filename):
return None return None
res = None
with self._openDB(filename) as f: with self._openDB(filename) as f:
return pickle.load(f) res = cPickle.load(f)
return None return res
def _callPlugins(self, target_root, *args): def _callPlugins(self, target_root, *args):
self.logger.info('==> Call plugins (%s)' % (target_root)) self.logger.info('==> Call plugins (%s)' % (target_root))