File: //usr/lib/python3/dist-packages/asgiref/__pycache__/current_thread_executor.cpython-310.pyc
o
�6�a�
� @ sB d dl Z d dlZd dlmZmZ G dd� d�ZG dd� de�ZdS )� N)�Executor�Futurec @ s e Zd ZdZdd� 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)
c C s || _ || _|| _|| _d S �N)�future�fn�args�kwargs)�selfr r r r � r �A/usr/lib/python3/dist-packages/asgiref/current_thread_executor.py�__init__ s
z_WorkItem.__init__c
C sn | j �� sd S z| j| ji | j��}W n ty. } z| j �|� d } W Y d }~d S d }~ww | j �|� d S r )r �set_running_or_notify_cancelr r r �
BaseException�
set_exception�
set_result)r
�result�excr r r �run s
��z
_WorkItem.runN)�__name__�
__module__�__qualname__�__doc__r
r r r r r r s r c @ s( e Zd ZdZdd� 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.
c C s t �� | _t�� | _d| _d S )NF)� threading�current_thread�_work_thread�queue�Queue�_work_queue�_broken)r
r r r r
&