
    +j\                     N    d dl mZ  G d de          Z G d dee          ZdS )    )TypeVarc                   |     e Zd Z edd           Zi Z fdZdee         deddfdZdee         def fd	Z	 xZ
S )
SingletonMetaclassT)boundc                     | | j         vr( t          t          |           j        |i || j         | <   | j         |          S N)
_instancessuperr   __call__clsargskwargs	__class__s      </home/wildlama/comfy/ComfyUI/comfy_api/internal/singleton.pyr   zSingletonMetaclass.__call__   sP    cn$$"I%(:C"@"@"I## #CN3 ~c""    r   instancereturnNc                 T    | t           j        vs
J d            |t           j        | <   d S )Nz0Cannot inject instance after first instantiation)r   r
   )r   r   s     r   inject_instancez"SingletonMetaclass.inject_instance   s8    ,7777> 877 .6%c***r   c                     | t           j        vr- t          t           |           j        |i |t           j        | <   | j        |          S )z\
        Gets the singleton instance of the class, creating it if it doesn't exist.
        )r   r
   r   r   r   s      r   get_instancezSingletonMetaclass.get_instance   s[     (3332"C2 22( &2( 2()#. ~c""r   )__name__
__module____qualname__r   r   r
   r   typer   r   __classcell__r   s   @r   r   r      s        /000AJ# # # # #6T!W 6 6d 6 6 6 6#$q' #q # # # # # # # # # #r   r   c                        e Zd Z fdZ xZS )ProxiedSingletonc                 H    t                                                       d S r	   )r   __init__)selfr   s    r   r#   zProxiedSingleton.__init__    s    r   )r   r   r   r#   r   r   s   @r   r!   r!      s8                r   r!   )	metaclassN)typingr   r   r   objectr!    r   r   <module>r)      s}         # # # # # # # #8    v);      r   