mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-03-04 07:43:46 +08:00
avoid repeatedly instantiating bot
This commit is contained in:
9
common/singleton.py
Normal file
9
common/singleton.py
Normal file
@@ -0,0 +1,9 @@
|
||||
def singleton(cls):
|
||||
instances = {}
|
||||
|
||||
def get_instance(*args, **kwargs):
|
||||
if cls not in instances:
|
||||
instances[cls] = cls(*args, **kwargs)
|
||||
return instances[cls]
|
||||
|
||||
return get_instance
|
||||
Reference in New Issue
Block a user