https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/asgiref/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/asgiref/__pycache__/local.cpython-310.pyc
o

�6�a��@s:ddlZddlZddlZddlZddlZGdd�d�ZdS)�Ncs\eZdZdZddeddfdd�Zdd	�Zd
d�Zdd
�Zdd�Z	�fdd�Z
dd�Z�ZS)�Locala�
    A drop-in replacement for threading.locals that also works with asyncio
    Tasks (via the current_task asyncio method), and passes locals through
    sync_to_async and async_to_sync.

    Specifically:
     - Locals work per-coroutine on any thread not spawned using asgiref
     - Locals work per-thread on any thread not spawned using asgiref
     - Locals are shared with the parent coroutine when using sync_to_async
     - Locals are shared with the parent thread when using async_to_sync
       (and if that thread was launched using sync_to_async, with its parent
       coroutine as well, with this working for indefinite levels of nesting)

    Set thread_critical to True to not allow locals to pass from an async Task
    to a thread it spawns. This is needed for code that truly needs
    thread-safety, as opposed to things used for helpful context (e.g. sqlite
    does not like being called from a different thread to the one it is from).
    Thread-critical code will still be differentiated per-Task within a thread
    as it is expected it does not like concurrent access.

    This doesn't use contextvars as it needs to support 3.6. Once it can support
    3.7 only, we can then reimplement the storage more nicely.
    F�thread_critical�returnNcCsD||_t��|_t��|_d�t|�d�	dd�t
d�D���|_dS)Nz_asgiref_local_impl_{}_{}�css�|]	}t�tj�VqdS�N)�random�choice�string�
ascii_letters)�.0�i�r
�//usr/lib/python3/dist-packages/asgiref/local.py�	<genexpr>)s�z!Local.__init__.<locals>.<genexpr>�)�_thread_critical�	threading�RLock�_thread_lock�weakref�WeakSet�
_context_refs�format�id�join�range�
_attr_name)�selfrr
r
r�__init__!s


�zLocal.__init__c	Cs�ddlm}m}|��}d}|durt��}d}|jr|Stt�	��D] }z|r0|j
|}d}n|j
|}d}Wq#tyCY|Swtd��)zC
        Get the ID we should use for looking up variables
        �)�AsyncToSync�SyncToAsyncTNFzInfinite launch_map loops)
�syncr r!�get_current_taskr�current_threadrr�sys�getrecursionlimit�
launch_map�KeyError�RuntimeError)rr r!�
context_id�context_is_asyncrr
r
r�_get_context_id,s*

��zLocal._get_context_idcCs:|��}t||j�st||ji�|j�|�t||j�Sr)r,�hasattrr�setattrr�add�getattr�r�context_objr
r
r�_get_storagePs
zLocal._get_storagec	CsJz|jD]}zt||j�WqtyYqwWdSty$YdSwr)r�delattrr�AttributeError�	TypeErrorr1r
r
r�__del__Ws
���z
Local.__del__cCsT|j�|��}||vr||Wd�St|�d|����1s#wYdS�Nz object has no attribute �rr3r5�r�key�storager
r
r�__getattr__cs��zLocal.__getattr__csR|dvrt��||�S|j�|��}|||<Wd�dS1s"wYdS)N)rrrr)�super�__setattr__rr3)rr;�valuer<��	__class__r
rr?ks
"�zLocal.__setattr__cCsV|j�|��}||vr||=n	t|�d|����Wd�dS1s$wYdSr8r9r:r
r
r�__delattr__rs�"�zLocal.__delattr__)F)
�__name__�
__module__�__qualname__�__doc__�boolrr,r3r7r=r?rC�
__classcell__r
r
rArrs$r)rr	r%rrrr
r
r
r�<module>s

https://t.me/RX1948 - 2025