We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 8d55408 + 7dc6ed0 commit 22ed17cCopy full SHA for 22ed17c
1 file changed
src/dcd_mapping/lookup.py
@@ -162,14 +162,17 @@ class GeneNormalizerBuilder:
162
"""Singleton constructor for Gene Normalizer instance."""
163
164
def __new__(cls) -> QueryHandler:
165
- """Provide Gene Normalizer instance. Construct it if unavailable.
+ """Provide Gene Normalizer instance. If an instance has already been
166
+ constructed, close its connection and provide a new one.
167
168
:return: singleton instance of ``QueryHandler`` for Gene Normalizer
169
"""
- if not hasattr(cls, "instance"):
170
- db = create_db()
171
- q = QueryHandler(db)
172
- cls.instance = q
+ if hasattr(cls, "instance"):
+ cls.instance.db.close_connection()
+ cls.instance = None
173
+
174
+ db = create_db()
175
+ cls.instance = QueryHandler(db)
176
return cls.instance
177
178
0 commit comments