HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/asgiref/__pycache__/current_thread_executor.cpython-310.pyc
o

�6�a�
�@sBddlZddlZddlmZmZGdd�d�ZGdd�de�ZdS)�N)�Executor�Futurec@s eZdZdZdd�Zdd�ZdS)�	_WorkItemz�
    Represents an item needing to be run in the executor.
    Copied from ThreadPoolExecutor (but it's private, so we're not going to rely on importing it)
    cCs||_||_||_||_dS�N)�future�fn�args�kwargs)�selfrrrr	�r�A/usr/lib/python3/dist-packages/asgiref/current_thread_executor.py�__init__s
z_WorkItem.__init__c
Csn|j��sdSz|j|ji|j��}Wnty.}z|j�|�d}WYd}~dSd}~ww|j�|�dSr)r�set_running_or_notify_cancelrrr	�
BaseException�
set_exception�
set_result)r
�result�excrrr�runs
��z
_WorkItem.runN)�__name__�
__module__�__qualname__�__doc__r
rrrrrrsrc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�CurrentThreadExecutorz�
    An Executor that actually runs code in the thread it is instantiated in.
    Passed to other threads running async code, so they can run sync code in
    the thread they came from.
    cCst��|_t��|_d|_dS)NF)�	threading�current_thread�_work_thread�queue�Queue�_work_queue�_broken)r
rrrr
&s


zCurrentThreadExecutor.__init__cCsZt��|jkrtd��|�|jj�z	|j��}||ur#Wd|_dS|�	�~qd|_w)z�
        Runs the code in the work queue until a result is available from the future.
        Should be run from the thread the executor is initialised in.
        z<You cannot run CurrentThreadExecutor from a different threadTN)
rrr�RuntimeError�add_done_callbackr�put�getr r)r
r�	work_itemrrr�run_until_future+s�

��z&CurrentThreadExecutor.run_until_futurecOsHt��|jkrtd��|jrtd��t�}t||||�}|j�|�|S)Nz@You cannot submit onto CurrentThreadExecutor from its own threadz/CurrentThreadExecutor already quit or is broken)	rrrr!r rrrr#)r
rrr	�fr%rrr�submitCs�zCurrentThreadExecutor.submitN)rrrrr
r&r(rrrrrs
r)rr�concurrent.futuresrrrrrrrr�<module>s