Ë
    ñuki	  ã                  óž   — d Z ddlmZ ddlZddlZddlmZ ddlmZ  ej                  d¬«       G d„ d	«      «       Z
 G d
„ d«      Z e«       Zy)z!Backend for colocated_python.obj.é    )ÚannotationsN)ÚAny)ÚCallableT)Úfrozenc                  ó4   — e Zd ZU ded<   dZded<   dZded<   y)Ú_ObjectStateÚboolÚis_being_initializedNzException | NoneÚexcr   Úobj)Ú__name__Ú
__module__Ú__qualname__Ú__annotations__r   r   © ó    úh/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/jax/experimental/colocated_python/obj_backend.pyr   r      s   … àÓØ€#ÐÓØ€#€s„/r   r   c                  ó(   — e Zd ZdZdd„Zdd„Zdd„Zy)	Ú_ObjectStorezStores live objects.c                óD   — t        j                  «       | _        i | _        y )N)Ú	threadingÚ	ConditionÚ_lockÚ_storage)Úselfs    r   Ú__init__z_ObjectStore.__init__"   s   € Ü×$Ñ$Ó&€D„JØ-/€D…Mr   c                óì  — | j                   5  || j                  v rf	 | j                  |   }|j                  r| j                   j                  «        nnŒ8|j                  |j                  ‚|j
                  cddd«       S t        d¬«      | j                  |<   ddd«       	  |«       }| j                   5  t        d|¬«      | j                  |<   | j                   j                  «        |cddd«       S # 1 sw Y   Œ]xY w# t        $ r[}| j                   5  t        d|¬«      | j                  |<   | j                   j                  «        ddd«       ‚ # 1 sw Y   ‚ xY wd}~ww xY w# 1 sw Y   yxY w)zUReturns the object associated with the given uid, or creates it if it does not exist.TN)r
   F)r
   r   )r
   r   )	r   r   r
   Úwaitr   r   r   Ú	ExceptionÚ
notify_all)r   ÚuidÚinitializerÚstater   r   s         r   Úget_or_createz_ObjectStore.get_or_create&   sH  € à	‰ñ CØ	—‘Ñ	ØØ—-‘- Ñ$ˆ%Ø×'Ò'àJ‰JO‰OÕàð ð 9‰9Ð Ø—	‘	ˆ/Øy‰y÷Cñ Cô (¸TÔB€d‡mmCÑ÷Cð Ù‹M€cð 
‰ñ Ü'¸UÈÔL€d‡mmCÑØ
‡jj×ÑÔØ÷ñ ÷1Cð Cûô$ ò Ø:‰:ñ  Ü)¸uÈ#ÔNˆ‰cÑØ
‰
×ÑÔ÷ ð ÷ ð þð	ú÷ð úsN   A+C7ÂC7Â$D Â76E*Ã7D Ä	E'ÄE"Ä5EÅ	E"ÅE	ÅE"Å"E'Å*E3c                ó€   — | j                   5  | j                  j                  |«      }ddd«       ~y# 1 sw Y   ~yxY w)z1Removes the object associated with the given uid.N)r   r   Úpop)r   r!   r#   s      r   Úremovez_ObjectStore.removeE   s7   € à	‰ñ %Øm‰m×Ñ Ó$€e÷%ñ 	÷	%ñ 	ús   3³=N)ÚreturnÚNone)r!   Úintr"   zCallable[[], Any]r(   r   )r!   r*   r(   r)   )r   r   r   Ú__doc__r   r$   r'   r   r   r   r   r      s   „ Ùó0óô>r   r   )r+   Ú
__future__r   Údataclassesr   Útypingr   Úcollections.abcr   Ú	dataclassr   r   ÚSINGLETON_OBJECT_STOREr   r   r   ú<module>r2      sT   ðñ (å "ã Û Ý Ý $ð €×Ñ˜dÔ#÷ð ó $ð÷,ñ ,ñ^ &›Ñ r   