Skip to content

Commit 22ed17c

Browse files
authored
Merge pull request #24 from VariantEffect/feature/bencap/23/gene-normalizer-connection-often-closed
Always Create a New Gene Normalizer Instance
2 parents 8d55408 + 7dc6ed0 commit 22ed17c

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/dcd_mapping/lookup.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,17 @@ class GeneNormalizerBuilder:
162162
"""Singleton constructor for Gene Normalizer instance."""
163163

164164
def __new__(cls) -> QueryHandler:
165-
"""Provide Gene Normalizer instance. Construct it if unavailable.
165+
"""Provide Gene Normalizer instance. If an instance has already been
166+
constructed, close its connection and provide a new one.
166167
167168
:return: singleton instance of ``QueryHandler`` for Gene Normalizer
168169
"""
169-
if not hasattr(cls, "instance"):
170-
db = create_db()
171-
q = QueryHandler(db)
172-
cls.instance = q
170+
if hasattr(cls, "instance"):
171+
cls.instance.db.close_connection()
172+
cls.instance = None
173+
174+
db = create_db()
175+
cls.instance = QueryHandler(db)
173176
return cls.instance
174177

175178

0 commit comments

Comments
 (0)