Move singleton to common utils

Signed-off-by: Katarzyna Treder <katarzyna.treder@h-partners.com>
This commit is contained in:
Katarzyna Treder
2024-12-10 13:24:33 +01:00
parent 5409fa9a40
commit de4305af8c
3 changed files with 1 additions and 1 deletions

View File

View File

@@ -0,0 +1,16 @@
#
# Copyright(c) 2019-2021 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
class Singleton(type):
"""
Singleton class
"""
_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]