HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberPanel/lib64/python3.10/site-packages/asgiref/__pycache__/local.cpython-310.pyc
o

��h0�@sTddlZddlZddlZddlZddlmZmZmZGdd�d�ZGdd�d�Z	dS)�N)�Any�Dict�UnioncsReZdZdZddd�Zdd�Zded	eddf�fd
d�Zdeddfdd
�Z	�Z
S)�_CVarzStorage utility for Local.�returnNcCst�d�|_dS)Nz
asgiref.local)�contextvars�
ContextVar�_data)�self�r�C/usr/local/CyberPanel/lib/python3.10/site-packages/asgiref/local.py�__init__s
�z_CVar.__init__cCs8|j�i�}z||WStyt|�d|����w�Nz object has no attribute )r	�get�KeyError�AttributeError�r
�key�storage_objectrrr�__getattr__s
�z_CVar.__getattr__r�valuecs>|dkrt��||�S|j�i���}|||<|j�|�dS)Nr	)�super�__setattr__r	r�copy�set)r
rrr��	__class__rrrs
z_CVar.__setattr__cCs@|j�i���}||vr||=|j�|�dSt|�d|����r)r	rrrrrrrr�__delattr__s
z_CVar.__delattr__)rN)�__name__�
__module__�__qualname__�__doc__r
r�strrrr�
__classcell__rrrrrs
rcsReZdZdZddeddfdd�Zejdd	��Zd
d�Z	�fdd
�Z
dd�Z�ZS)�LocalaLocal 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.
    F�thread_criticalrNcCs2||_t��|_||rt��|_dSt�|_dS�N)�_thread_critical�	threading�RLock�_thread_lock�local�_storager)r
r%rrrr
Ds
zLocal.__init__ccs��|jr2d}zt��Wntyd}Ynw|s |jVdSt|jd�s+t�|j_|jjVdS|j�
|jVWd�dS1sEwYdS)NTF�cvar)	r'�asyncio�get_running_loop�RuntimeErrorr,�hasattrrr-r*)r
�is_asyncrrr�
_lock_storageQs ��

"�zLocal._lock_storagecCs6|���
}t||�Wd�S1swYdSr&)r3�getattr�r
r�storagerrrrws
$�zLocal.__getattr__csP|dvrt��||�S|���}t|||�Wd�dS1s!wYdS)N)�_localr,r'r*)rrr3�setattr)r
rrr6rrrr{s

"�zLocal.__setattr__cCs8|���}t||�Wd�dS1swYdSr&)r3�delattrr5rrrr�s
"�zLocal.__delattr__)F)
rrr r!�boolr
�
contextlib�contextmanagerr3rrrr#rrrrr$(s
%r$)
r.r;rr(�typingrrrrr$rrrr�<module>s