diff --git a/src/database/Connector.py b/src/database/Connector.py index 808ba273a05d511674af80283162bc105571ee93..3641bcd46d73fd64ee0ad8a8b1471e7f7adab609 100644 --- a/src/database/Connector.py +++ b/src/database/Connector.py @@ -1,14 +1,7 @@ from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker from scrapy.conf import settings - - -class Singleton(type): - _instances = {} - def __call__(cls, *args, **kwargs): - if cls not in cls._instances: - cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs) - return cls._instances[cls] +from utils.Singleton import Singleton class Connector(metaclass=Singleton): diff --git a/src/utils/Singleton.py b/src/utils/Singleton.py new file mode 100644 index 0000000000000000000000000000000000000000..0ef78444aab817558f3fbc3a75c525bb32c9553c --- /dev/null +++ b/src/utils/Singleton.py @@ -0,0 +1,9 @@ + + +class Singleton(type): + _instances = {} + + def __call__(cls, *args, **kwargs): + if cls not in cls._instances: + cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs) + return cls._instances[cls] \ No newline at end of file diff --git a/src/utils/__init__.py b/src/utils/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391