Ë
    àëjˆ  ã                   ó¾   — d dl Z d dlZd dlZd dlmZmZ  G d„ d«      Zdd„Zej                  Z
 G d„ d«      Ze G d„ d	«      «       Z G d
„ de«      Z G d„ de«      Zy)é    N)ÚAnyÚfinalc                   ó2   — e Zd ZdZdZdedeeef   ddfd„Z	y)Ú_Storagean  Thread-tagged storage for a non-thread-critical ``Local``.

    The data is tagged with the identity of the thread that owns it. This lets
    ``_CVar`` ignore data that leaked into an unrelated thread.

    Python 3.14 added ``sys.flags.thread_inherit_context``, which is enabled by
    default on free-threaded builds. When set, a new thread starts with a copy
    of the spawning thread's context instead of an empty one, so the contextvar
    backing a ``Local`` would otherwise be visible in any thread spawned from
    one that had set it -- breaking the documented "thread-local in sync
    threads" behaviour. asgiref re-homes the storage to the current thread at
    the points where it *intentionally* moves work between threads (see
    ``asgiref.sync._restore_context``); data merely inherited by an unrelated
    thread is never re-homed and so stays isolated.
    ©Ú	thread_idÚdatar   r	   ÚreturnNc                 ó    — || _         || _        y ©Nr   )Úselfr   r	   s      úS/var/www/html/nexus_chitfund_web/venv/lib/python3.12/site-packages/asgiref/local.pyÚ__init__z_Storage.__init__   s   € Ø"ˆŒØˆ�	ó    )
Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__ÚintÚdictÚstrr   r   © r   r   r   r      s0   „ ñð  &€Ið #ð ¨T°#°s°(©^ð Àô r   r   c                 óR   — t        t        j                  «       | j                  «      S )z7Return a copy of *storage* owned by the current thread.)r   Ú	threadingÚ	get_identr	   )Ústorages    r   Ú_rehomer      s   € ä”I×'Ñ'Ó)¨7¯<©<Ó8Ð8r   c                   óV   — e Zd ZU dZded<   dd„Zdd„Zd„ Zd	ed
e	ddfd„Z
d	eddfd„Zy)Ú_CVarzStorage utility for Local.z contextvars.ContextVar[_Storage]Ú_datar
   Nc                 óD   — t        | dt        j                  d«      «       y )Nr!   zasgiref.local)Ú_object_setattrÚcontextvarsÚ
ContextVar©r   s    r   r   z_CVar.__init__,   s   € Ü˜˜g¤{×'=Ñ'=¸oÓ'NÕOr   c                 ó¾   — | j                   j                  d «      }|�!|j                  t        j                  «       k7  rt        t        j                  «       i «      S |S r   )r!   Úgetr   r   r   r   )r   r   s     r   Ú_storagez_CVar._storage/   sL   € ð —*‘*—.‘. Ó&ˆØˆ?˜g×/Ñ/´9×3FÑ3FÓ3HÒHÜœI×/Ñ/Ó1°2Ó6Ð6Øˆr   c                 óx   — 	 | j                  «       j                  |   S # t        $ r t        | ›d|›�«      ‚w xY w©Nz object has no attribute )r)   r	   ÚKeyErrorÚAttributeError©r   Úkeys     r   Ú__getattr__z_CVar.__getattr__8   sG   € ð	NØ—=‘=“?×'Ñ'¨Ñ,Ð,øÜò 	NÜ  D 8Ð+DÀSÀGÐ!LÓMÐMð	Nús   ‚ Ÿ9r/   Úvaluec                 óì   — |dk(  rt        d«      ‚| j                  «       j                  j                  «       }|||<   | j                  j                  t        t        j                  «       |«      «       y )Nr!   z%Cannot set attribute '_data' on Local)	r-   r)   r	   Úcopyr!   Úsetr   r   r   )r   r/   r1   r	   s       r   Ú__setattr__z_CVar.__setattr__>   sX   € Ø�'Š>Ü Ð!HÓIÐIà�}‰}‹×#Ñ#×(Ñ(Ó*ˆØˆˆS‰	Ø�
‰
�‰”x¤	× 3Ñ 3Ó 5°tÓ<Õ=r   c                 óð   — | j                  «       j                  j                  «       }||v r;||= | j                  j	                  t        t        j                  «       |«      «       y t        | ›d|›�«      ‚r+   )	r)   r	   r3   r!   r4   r   r   r   r-   )r   r/   r	   s      r   Ú__delattr__z_CVar.__delattr__F   sa   € Ø�}‰}‹×#Ñ#×(Ñ(Ó*ˆØ�$‰;Ø�S�	Ø�J‰J�N‰Nœ8¤I×$7Ñ$7Ó$9¸4Ó@ÕAä  D 8Ð+DÀSÀGÐ!LÓMÐMr   )r
   N)r
   r   )r   r   r   r   Ú__annotations__r   r)   r0   r   r   r5   r7   r   r   r   r    r    '   sL   … Ù$à-Ó-óPóòNð>˜sð >¨3ð >°4ó >ðN˜sð N tô Nr   r    c                   óh   — e Zd ZdZddedd fd„Zddeddfd„Zdedefd„Z	ded	edefd
„Z
dedefd„Zy)ÚLocala  Local storage for async tasks.

    This is a namespace object (similar to `threading.local`) where data is
    also local to the current async task (if there is one).

    In async threads, local means in the same sense as the `contextvars`
    module - i.e. a value set in an async frame will be visible:

    - to other async code `await`-ed from this frame.
    - to tasks spawned using `asyncio` utilities (`create_task`, `wait_for`,
      `gather` and probably others).
    - to code scheduled in a sync thread using `sync_to_async`

    In "sync" threads (a thread with no async event loop running), the
    data is thread-local, but additionally shared with async code executed
    via the `async_to_sync` utility, which schedules async code in a new thread
    and copies context across to that thread.

    If `thread_critical` is True, then the local will only be visible per-thread,
    behaving exactly like `threading.local` if the thread is sync, and as
    `contextvars` if the thread is async. This allows genuinely thread-sensitive
    code (such as DB handles) to be kept strictly to their initial thread and
    disable the sharing across `sync_to_async` and `async_to_sync` wrapped calls.

    Unlike plain `contextvars` objects, this utility is threadsafe.
    Úthread_criticalr
   c                 ó�   — | t         urt        d«      ‚|rt        j                  t        «      S t        j                  t
        «      S )Nz(asgiref.local.Local cannot be subclassed)r:   Ú	TypeErrorÚobjectÚ__new__Ú_ThreadCriticalLocalÚ_DefaultLocal)Úclsr;   s     r   r?   zLocal.__new__l   s8   € Ø”eÑÜÐFÓGÐGáÜ—>‘>Ô"6Ó7Ð7Ü�~‰~œmÓ,Ð,r   Nc                  ó   — y r   r   )r   r;   s     r   r   zLocal.__init__t   s   € ð 	r   r/   c                  ó   — y r   r   r.   s     r   r0   zLocal.__getattr__}   ó   € ¨Cr   r1   c                  ó   — y r   r   ©r   r/   r1   s      r   r5   zLocal.__setattr__   s   € ¸r   c                  ó   — y r   r   r.   s     r   r7   zLocal.__delattr__�   rE   r   ©F)r   r   r   r   Úboolr?   r   r   r   r0   r5   r7   r   r   r   r:   r:   O   s[   „ ññ6- dð -°wó -ñ¨ð ¸ó ð 0˜sÐ/ sÓ/à;˜sÐ;¨3Ð;°3Ó;à/˜sÐ/ sÔ/r   r:   c                   ó@   ‡ — e Zd ZdZd	deddfˆ fd„Zd„ Zd„ Zd„ Zˆ xZ	S )
rA   zCLocal with thread_critical=False: CVar storage protected by a lock.r;   r
   Nc                 ó�   •— t         ‰| �  |«       t        «       }t        | dt	        j
                  «       «       t        | d|«       y )NÚ_lockr)   )Úsuperr   r    r#   r   ÚRLock)r   r;   r   Ú	__class__s      €r   r   z_DefaultLocal.__init__‡   s6   ø€ Ü‰Ñ˜Ô)Ü“'ˆÜ˜˜g¤y§¡Ó'8Ô9Ü˜˜j¨'Õ2r   c                 óÖ   — | j                   j                  «        	 t        | j                  |«      | j                   j	                  «        S # | j                   j	                  «        w xY wr   )rM   ÚacquireÚgetattrr)   Úreleaser.   s     r   r0   z_DefaultLocal.__getattr__�   sF   € à�
‰
×ÑÔð	!Ü˜4Ÿ=™=¨#Ó.à�J‰J×ÑÕ øˆD�J‰J×ÑÕ ús   œA ÁA(c                 óÚ   — | j                   j                  «        	 t        | j                  ||«       | j                   j	                  «        y # | j                   j	                  «        w xY wr   )rM   rR   Úsetattrr)   rT   rG   s      r   r5   z_DefaultLocal.__setattr__•   sH   € à�
‰
×ÑÔð	!Ü�D—M‘M 3¨Ô.à�J‰J×ÑÕ øˆD�J‰J×ÑÕ ús   œA ÁA*c                 óØ   — | j                   j                  «        	 t        | j                  |«       | j                   j	                  «        y # | j                   j	                  «        w xY wr   )rM   rR   Údelattrr)   rT   r.   s     r   r7   z_DefaultLocal.__delattr__�   sF   € à�
‰
×ÑÔð	!Ü�D—M‘M 3Ô'à�J‰J×ÑÕ øˆD�J‰J×ÑÕ ús   œA ÁA)rI   )
r   r   r   r   rJ   r   r0   r5   r7   Ú__classcell__©rP   s   @r   rA   rA   „   s(   ø„ ÙMñ3¨ð 3¸õ 3ò!ò!ö!r   rA   c                   óF   ‡ — e Zd ZdZd
deddfˆ fd„Zd„ Zd„ Zd„ Zd	„ Z	ˆ xZ
S )r@   zELocal with thread_critical=True: thread-local storage, CVar in async.r;   r
   Nc                 ób   •— t         ‰| �  |«       t        | dt        j                  «       «       y )Nr)   )rN   r   r#   r   Úlocal)r   r;   rP   s     €r   r   z_ThreadCriticalLocal.__init__©   s#   ø€ Ü‰Ñ˜Ô)Ü˜˜j¬)¯/©/Ó*;Õ<r   c                 óì   — 	 t        j                  «        t	        | j                  d«      st        «       | j                  _        | j                  j                  S # t        $ r | j                  cY S w xY w)NÚcvar)ÚasyncioÚget_running_loopÚRuntimeErrorr)   Úhasattrr    r_   r&   s    r   Ú_get_storagez!_ThreadCriticalLocal._get_storage­   s`   € ð	!Ü×$Ñ$Ô&ô �t—}‘} fÔ-Ü!&£ˆD�M‰MÔð
 �}‰}×!Ñ!Ð!øô' ò 	!ð
 —=‘=Ò ð	!ús   ‚A ÁA3Á2A3c                 ó6   — t        | j                  «       |«      S r   )rS   rd   r.   s     r   r0   z _ThreadCriticalLocal.__getattr__Å   s   € Ü�t×(Ñ(Ó*¨CÓ0Ð0r   c                 ó:   — t        | j                  «       ||«       y r   )rV   rd   rG   s      r   r5   z _ThreadCriticalLocal.__setattr__È   s   € Ü�×!Ñ!Ó# S¨%Õ0r   c                 ó8   — t        | j                  «       |«       y r   )rX   rd   r.   s     r   r7   z _ThreadCriticalLocal.__delattr__Ë   s   € Ü�×!Ñ!Ó# SÕ)r   rI   )r   r   r   r   rJ   r   rd   r0   r5   r7   rY   rZ   s   @r   r@   r@   ¦   s-   ø„ ÙOñ=¨ð =¸õ =ò"ò01ò1ö*r   r@   )r   r   r
   r   )r`   r$   r   Útypingr   r   r   r   r>   r5   r#   r    r:   rA   r@   r   r   r   Ú<module>ri      sm   ðÛ Û Û ß ÷ñ ó09ð
 ×$Ñ$€÷%Nñ %NðP ÷10ð 10ó ð10ôh!�Eô !ôD&*˜5õ &*r   