mirror of
https://github.com/fxsjy/jieba.git
synced 2025-07-24 00:00:05 +08:00
fix a bug of file leak
This commit is contained in:
parent
1275b3679f
commit
ff4ea5d882
@ -81,7 +81,8 @@ def initialize(*args):
|
|||||||
min_freq = min(FREQ.itervalues())
|
min_freq = min(FREQ.itervalues())
|
||||||
print >> sys.stderr, "dumping model to file cache " + cache_file
|
print >> sys.stderr, "dumping model to file cache " + cache_file
|
||||||
tmp_suffix = "."+str(random.random())
|
tmp_suffix = "."+str(random.random())
|
||||||
marshal.dump((trie,FREQ,total,min_freq),open(cache_file+tmp_suffix,'wb'))
|
with open(cache_file+tmp_suffix,'wb') as temp_cache_file:
|
||||||
|
marshal.dump((trie,FREQ,total,min_freq),temp_cache_file)
|
||||||
if os.name=='nt':
|
if os.name=='nt':
|
||||||
import shutil
|
import shutil
|
||||||
replace_file = shutil.move
|
replace_file = shutil.move
|
||||||
|
Loading…
x
Reference in New Issue
Block a user