Added exception checking for pickle format conversion
This commit is contained in:
@@ -110,7 +110,7 @@ def extract_signature(msg_body):
|
||||
|
||||
return (stripped_body.strip(),
|
||||
signature.strip())
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
log.exception('ERROR extracting signature')
|
||||
return (msg_body, None)
|
||||
|
||||
|
||||
@@ -35,11 +35,16 @@ def load(saved_classifier_filename, train_data_filename):
|
||||
try:
|
||||
return joblib.load(saved_classifier_filename)
|
||||
except ValueError:
|
||||
# load python 2 pickle format with python 3, and save it permissions allowing
|
||||
import sys
|
||||
kwargs = {}
|
||||
if sys.version_info > (3, 0):
|
||||
kwargs["encoding"] = "latin1"
|
||||
|
||||
loaded = pickle.load(open(saved_classifier_filename, 'rb'), **kwargs)
|
||||
try:
|
||||
joblib.dump(loaded, saved_classifier_filename, compress=True)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return joblib.load(saved_classifier_filename)
|
||||
|
||||
Reference in New Issue
Block a user