Added libs
This commit is contained in:
19
fspn/utils/wrapper_util.py
Normal file
19
fspn/utils/wrapper_util.py
Normal file
@@ -0,0 +1,19 @@
|
||||
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
|
||||
Reference in New Issue
Block a user