Coverage for graphqler / utils / singleton.py: 100%

8 statements  

« prev     ^ index     » next       coverage.py v7.13.4, created at 2026-03-20 10:09 -0400

1def singleton(myClass): 

2 instances = {} 

3 

4 def getInstance(*args, **kwargs): 

5 if myClass not in instances: 

6 instances[myClass] = myClass(*args, **kwargs) 

7 return instances[myClass] 

8 

9 # Expose the original class so callers can create fresh non-singleton instances 

10 # when needed (e.g. per-chain ObjectsBucket in the fuzzer): 

11 # fresh_bucket = ObjectsBucket.__wrapped__(api) 

12 getInstance.__wrapped__ = myClass 

13 

14 return getInstance