mirror of
https://github.com/veekun/pokedex.git
synced 2024-08-20 18:16:34 +00:00
Close csv files after dumping
PyPy doesn't collect garbage as quickly as CPython, so it was possible for the process to exit before all the files had been flushed.
This commit is contained in:
parent
68ee98ffdd
commit
348742fe2a
1 changed files with 5 additions and 2 deletions
|
@ -441,10 +441,12 @@ def dump(session, tables=[], directory=None, verbose=False, langs=None):
|
|||
|
||||
# CSV module only works with bytes on 2 and only works with text on 3!
|
||||
if six.PY3:
|
||||
writer = csv.writer(open(filename, 'w', newline='', encoding="utf8"), lineterminator='\n')
|
||||
csvfile = open(filename, 'w', newline='', encoding="utf8")
|
||||
writer = csv.writer(csvfile, lineterminator='\n')
|
||||
columns = [col.name for col in table.columns]
|
||||
else:
|
||||
writer = csv.writer(open(filename, 'wb'), lineterminator='\n')
|
||||
csvfile = open(filename, 'wb')
|
||||
writer = csv.writer(csvfile, lineterminator='\n')
|
||||
columns = [col.name.encode('utf8') for col in table.columns]
|
||||
|
||||
# For name tables, always dump rows for official languages, as well as
|
||||
|
@ -491,4 +493,5 @@ def dump(session, tables=[], directory=None, verbose=False, langs=None):
|
|||
|
||||
writer.writerow(csvs)
|
||||
|
||||
csvfile.close()
|
||||
print_done()
|
||||
|
|
Loading…
Reference in a new issue