Skip to content

Commit

Permalink
Close ELMo resources in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AjayP13 committed Nov 8, 2018
1 parent 6ae8d57 commit f56383f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pymagnitude/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1956,6 +1956,20 @@ def close(self):
self.APPROX_MMAP_PROCESS_LOCK.lockfile.close()
except BaseException:
pass
if (hasattr(self, 'ELMO_W_MMAP_PROCESS_LOCK') and
hasattr(self.ELMO_W_MMAP_PROCESS_LOCK, 'lockfile') and
self.ELMO_W_MMAP_PROCESS_LOCK.lockfile is not None):
try:
self.ELMO_W_MMAP_PROCESS_LOCK.lockfile.close()
except BaseException:
pass
if (hasattr(self, 'ELMO_O_MMAP_PROCESS_LOCK') and
hasattr(self.ELMO_O_MMAP_PROCESS_LOCK, 'lockfile') and
self.ELMO_O_MMAP_PROCESS_LOCK.lockfile is not None):
try:
self.ELMO_O_MMAP_PROCESS_LOCK.lockfile.close()
except BaseException:
pass

def __del__(self):
""" Destructor for the class """
Expand Down
10 changes: 10 additions & 0 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,20 @@ def setUp(self):

def tearDown(self):
self.vectors.close()
self.vectors_un.close()
self.vectors_cs.close()
self.vectors_batch.close()
self.vectors_sw.close()
self.vectors_approx.close()
self.tmp_vectors.close()
try:
self.vectors_elmo.close()
self.vectors_elmo_p.close()
self.vectors_elmo_ngram.close()
self.vectors_elmo_ngram_p.close()
self.vectors_elmo_n.close()
except BaseException:
pass
self.concat_1.close()
self.concat_2.close()
del self.concat
Expand Down

0 comments on commit f56383f

Please sign in to comment.