Files
nosys_libs/fspn/utils/wrapper_util.py
2026-01-25 13:55:46 +10:00

20 lines
530 B
Python

import functools
from threading import Thread
def threaded(fn):
"""Decorator to automatically launch a function in a thread"""
@functools.wraps(fn)
def wrapper(*args, **kwargs):
thread = Thread(target=fn, args=args, kwargs=kwargs)
thread.start()
return thread
return wrapper
def singleton(cls):
instances = {}
def getinstance(*args, **kwargs):
if cls not in instances:
instances[cls] = cls(*args, **kwargs)
return instances[cls]
return getinstance