Skip to content

Commit f56383f

Browse files
committed
Close ELMo resources in tests
1 parent 6ae8d57 commit f56383f

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

pymagnitude/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1956,6 +1956,20 @@ def close(self):
19561956
self.APPROX_MMAP_PROCESS_LOCK.lockfile.close()
19571957
except BaseException:
19581958
pass
1959+
if (hasattr(self, 'ELMO_W_MMAP_PROCESS_LOCK') and
1960+
hasattr(self.ELMO_W_MMAP_PROCESS_LOCK, 'lockfile') and
1961+
self.ELMO_W_MMAP_PROCESS_LOCK.lockfile is not None):
1962+
try:
1963+
self.ELMO_W_MMAP_PROCESS_LOCK.lockfile.close()
1964+
except BaseException:
1965+
pass
1966+
if (hasattr(self, 'ELMO_O_MMAP_PROCESS_LOCK') and
1967+
hasattr(self.ELMO_O_MMAP_PROCESS_LOCK, 'lockfile') and
1968+
self.ELMO_O_MMAP_PROCESS_LOCK.lockfile is not None):
1969+
try:
1970+
self.ELMO_O_MMAP_PROCESS_LOCK.lockfile.close()
1971+
except BaseException:
1972+
pass
19591973

19601974
def __del__(self):
19611975
""" Destructor for the class """

tests/tests.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,20 @@ def setUp(self):
9191

9292
def tearDown(self):
9393
self.vectors.close()
94+
self.vectors_un.close()
9495
self.vectors_cs.close()
9596
self.vectors_batch.close()
9697
self.vectors_sw.close()
98+
self.vectors_approx.close()
9799
self.tmp_vectors.close()
100+
try:
101+
self.vectors_elmo.close()
102+
self.vectors_elmo_p.close()
103+
self.vectors_elmo_ngram.close()
104+
self.vectors_elmo_ngram_p.close()
105+
self.vectors_elmo_n.close()
106+
except BaseException:
107+
pass
98108
self.concat_1.close()
99109
self.concat_2.close()
100110
del self.concat

0 commit comments

Comments
 (0)