MCPcopy Create free account
hub / github.com/DVampire/FinAgent / Singleton

Class Singleton

finagent/utils/singleton.py:5–16  ·  view source on GitHub ↗

Singleton metaclass for ensuring only one instance of a class.

Source from the content-addressed store, hash-verified

3
4
5class Singleton(abc.ABCMeta, type):
6 """
7 Singleton metaclass for ensuring only one instance of a class.
8 """
9
10 _instances = {}
11
12 def __call__(cls, *args, **kwargs):
13 """Call method for the singleton metaclass."""
14 if cls not in cls._instances:
15 cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
16 return cls._instances[cls]
17
18
19class AbstractSingleton(abc.ABC, metaclass=Singleton):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected