
    hh0                     `    S SK r S SKrS SKrS SKrS SKJrJrJr   " S S5      r " S S5      r	g)    N)AnyDictUnionc                   ^   ^  \ rS rSrSrSS jrS rS\S\SS4U 4S	 jjr	S\SS4S
 jr
SrU =r$ )_CVar   zStorage utility for Local.returnNc                 :    [         R                  " S5      U l        g )Nzasgiref.local)contextvars
ContextVar_data)selfs    HD:\Anime\Ugyen\janka_web_project\venv\Lib\site-packages\asgiref/local.py__init___CVar.__init__   s    ?J?U?U@

    c                     U R                   R                  0 5      n X!   $ ! [         a    [        U < SU< 35      ef = fNz object has no attribute )r   getKeyErrorAttributeErrorr   keystorage_objects      r   __getattr___CVar.__getattr__   sK    +	N!&& 	N D8+DSG!LMM	Ns   ! >r   valuec                    > US:X  a  [         TU ]  X5      $ U R                  R                  0 5      R	                  5       nX#U'   U R                  R                  U5        g )Nr   )super__setattr__r   r   copyset)r   r   r   r   	__class__s       r   r    _CVar.__setattr__   sM    '>7&s22+002#s

~&r   c                     U R                   R                  0 5      R                  5       nX;   a  X!	 U R                   R                  U5        g [	        U < SU< 35      er   )r   r   r!   r"   r   r   s      r   __delattr___CVar.__delattr__   sP    +002 #JJNN>* D8+DSG!LMMr   )r   )r	   N)__name__
__module____qualname____firstlineno____doc__r   r   strr   r    r&   __static_attributes____classcell__r#   s   @r   r   r      sG    $

N's '3 '4 'Ns Nt N Nr   r   c                   r   ^  \ rS rSrSrSS\SS4S jjr\R                  S 5       r	S r
U 4S	 jrS
 rSrU =r$ )Local(   a  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 stricly 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	   Nc                     Xl         [        R                  " 5       U l        U   U(       a  [        R                  " 5       U l        g [        5       U l        g N)_thread_critical	threadingRLock_thread_locklocal_storager   )r   r4   s     r   r   Local.__init__D   s6     /%OO-%OO-DM "GDMr   c              #     #    U R                   (       a{  Sn [        R                  " 5         U(       d  U R                  v   g [        U R                  S5      (       d  [        5       U R                  l        U R                  R                  v   g U R                     U R                  v   S S S 5        g ! [         a    Sn Nf = f! , (       d  f       g = f7f)NTFcvar)	r7   asyncioget_running_loopRuntimeErrorr<   hasattrr   r?   r:   )r   is_asyncs     r   _lock_storageLocal._lock_storageQ   s        H! ((* 
 mm# t}}f55).DMM&
 mm((( ""mm# #"3   ! !2 #"s@   CB3 A/CC*	C3C?CCC
CCc                 n    U R                  5        n[        X!5      sS S S 5        $ ! , (       d  f       g = fr6   )rE   getattrr   r   storages      r   r   Local.__getattr__w   s$    !W7( "!!s   &
4c                    > US;   a  [         TU ]  X5      $ U R                  5        n[        X1U5        S S S 5        g ! , (       d  f       g = f)N)_localr<   r7   r:   )r   r    rE   setattr)r   r   r   rJ   r#   s       r   r    Local.__setattr__{   s@    LL7&s22!WG%( "!!s	   =
Ac                 n    U R                  5        n[        X!5        S S S 5        g ! , (       d  f       g = fr6   )rE   delattrrI   s      r   r&   Local.__delattr__   s$    !WG! "!!s   &
4)r<   r7   r:   )F)r(   r)   r*   r+   r,   boolr   
contextlibcontextmanagerrE   r   r    r&   r.   r/   r0   s   @r   r2   r2   (   sJ    6$ $ $ #$ #$J))" "r   r2   )
r@   rT   r   r8   typingr   r   r   r   r2    r   r   <module>rX      s0        # #N N@[" ["r   