Skip to content

Commit

Permalink
Merge pull request #24 from VariantEffect/feature/bencap/23/gene-norm…
Browse files Browse the repository at this point in the history
…alizer-connection-often-closed

Always Create a New Gene Normalizer Instance
  • Loading branch information
bencap authored Oct 16, 2024
2 parents 8d55408 + 7dc6ed0 commit 22ed17c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/dcd_mapping/lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,17 @@ class GeneNormalizerBuilder:
"""Singleton constructor for Gene Normalizer instance."""

def __new__(cls) -> QueryHandler:
"""Provide Gene Normalizer instance. Construct it if unavailable.
"""Provide Gene Normalizer instance. If an instance has already been
constructed, close its connection and provide a new one.
:return: singleton instance of ``QueryHandler`` for Gene Normalizer
"""
if not hasattr(cls, "instance"):
db = create_db()
q = QueryHandler(db)
cls.instance = q
if hasattr(cls, "instance"):
cls.instance.db.close_connection()
cls.instance = None

db = create_db()
cls.instance = QueryHandler(db)
return cls.instance


Expand Down

0 comments on commit 22ed17c

Please sign in to comment.