Skip to content

Commit c76a1ec

Browse files
committed
provide the call to use free pyexcel resources: such open file handles
1 parent 68436f9 commit c76a1ec

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

pyexcel_webio/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,13 @@ def save_book_to_database(self, session=None, tables=None,
212212
params['dest_auto_commit'] = auto_commit
213213
pe.save_book_as(**params)
214214

215+
def free_resources(self):
216+
"""
217+
After you have used iget_array and iget_records, it's
218+
recommended to call this function
219+
"""
220+
pe.free_resources()
221+
215222

216223
class ExcelInputInMultiDict(ExcelInput):
217224
"""

tests/test_webio.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ def test_iget_array(self):
101101
myinput = TestInput()
102102
array = myinput.iget_array(file_name=self.testfile)
103103
assert list(array) == self.data
104+
myinput.free_resources()
104105

105106
def test_get_dict(self):
106107
myinput = TestInput()
@@ -126,6 +127,7 @@ def test_iget_records(self):
126127
{"X": 1, "Y": 2, "Z": 3},
127128
{"X": 4, "Y": 5, "Z": 6}
128129
]
130+
myinput.free_resources()
129131

130132
def test_save_to_database(self):
131133
Base.metadata.drop_all(engine)

0 commit comments

Comments
 (0)