ó
    ªRj0  ã                   ó`   • 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    Ú9D:\diplom_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Ü  D¡8Ð+DÀSÁGÐ!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ˆØÓ ØÐ#Ø�J‰J�N‰N˜>Õ*ä  D¡8Ð+DÀSÁGÐ!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   € Ø /ÔÜ%ŸOšOÓ-ˆÔáæä%ŸOšOÓ-ˆD�Mô "›GˆD�Mr   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 N•f = 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ð!ô ×(Ò(Ô*ö ð
 —m‘mÓ#ô ˜tŸ}™}¨f×5Ñ5Ü).«�D—M‘MÔ&ð
 —m‘m×(Ñ(Ó(ð ×"Ó"Ø—m‘mÒ#÷ #Ð"øô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   