File tree Expand file tree Collapse file tree 1 file changed +16
-8
lines changed Expand file tree Collapse file tree 1 file changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -780,12 +780,16 @@ def load_training():
780
780
log .info ("Loading training data from pickled file" )
781
781
try :
782
782
of = open (pickled_data , "rb" )
783
+ except Exception :
784
+ of = None
785
+ log .info ("Pickle file could not be read" )
786
+ if of is not None :
783
787
try :
784
788
p = pickle .load (of )
789
+ except Exception :
790
+ log .info ("Pickled training data could not be loaded" )
785
791
finally :
786
792
of .close ()
787
- except Exception :
788
- log .info ("Pickled training data could not be loaded" )
789
793
if p is None :
790
794
log .info ("No pickled training data, loading from corpus" )
791
795
t = TrainingData ()
@@ -795,16 +799,20 @@ def load_training():
795
799
log .info ("Saving pickled training data" )
796
800
try :
797
801
of = open (pickled_data , "wb" )
802
+ except Exception :
803
+ of = None
804
+ log .info ("Pickle file could not be written" )
805
+ if of is not None :
798
806
try :
799
807
pickle .dump (p , of )
808
+ except OSError :
809
+ log .warning ("Could not save cached training data" )
810
+ except TypeError :
811
+ # Sometimes fails with "can't pickle instancemethod objects"
812
+ log .warning ("Can't pickle with this version of python" )
813
+ os .unlink (pickled_data )
800
814
finally :
801
815
of .close ()
802
- except OSError :
803
- log .warning ("Could not save cached training data" )
804
- except TypeError :
805
- # Sometimes fails with "can't pickle instancemethod objects"
806
- log .warning ("Can't pickle with this version of python" )
807
- os .unlink (pickled_data )
808
816
return p
809
817
810
818
training_global_variable = None
You can’t perform that action at this time.
0 commit comments