U
    @f                     @   sD  d dl Z d dlZd dlmZ d dlZd dlmZ d dlmZ d dlmZm	Z	m
Z
 dddgZd	efd
e	fde
fgZd dlmZ edef ejde fe  edZejdeZejdkZeedddkrG dd deZnejZG dd dejZdd ZeejZeejZeedr6ed eej Z [ej!Z![dS )    N)FunctionType)greenio)patcher)select	threadingtimecall
check_callPopenr   r   r   )	selectorsr   
subprocesswin32TimeoutExpiredc                   @   s"   e Zd ZdZdddZdd ZdS )r   zeThis exception is raised when the timeout expires while waiting for
        a child process.
        Nc                 C   s   || _ || _|| _d S N)cmdtimeoutoutput)selfr   r   r    r   S/var/www/html/chatgpt/venv/lib/python3.8/site-packages/eventlet/green/subprocess.py__init__   s    zTimeoutExpired.__init__c                 C   s   d| j | jf S )Nz'Command '%s' timed out after %s seconds)r   r   )r   r   r   r   __str__$   s    
zTimeoutExpired.__str__)N)__name__
__module____qualname____doc__r   r   r   r   r   r   r      s   
c                   @   s   e Zd ZdZes&d	ddZejjje_d
ddZejjje_ese	ejj
je Z
z(e	ejjje Ze	ejjje ZW n ek
r   Y nX dS )r
   z-eventlet-friendly version of subprocess.Popenr   c           	      O   s   || _ tjj| |df|| dD ]z}t| |}|d k	r"t|tjkr"t|dd}|s| rf|d7 }|	 rv|d7 }|dkrd}t|||}t
| || q"d S )Nr   )stdinstdoutstderrmode rw)argssubprocess_origr
   r   getattrtyper   Z	GreenPipereadablewritablesetattr)	r   r$   bufsizeZargsskwdsattrpiper   Zwrapped_piper   r   r   r   5   s    
zPopen.__init__N{Gz?c              
   C   s   |d k	rt   | }zF|  }|d k	r,|W S |d k	rLt   |krLt| j|t| qW n: tk
r } z|jtjkrW Y 
dS  W 5 d }~X Y nX d S )Nr#   )	r   pollr   r$   eventletsleepOSErrorerrnoZECHILD)r   r   Zcheck_intervalendtimestatuser   r   r   waitM   s    
z
Popen.wait)r   )Nr/   )r   r   r   r   	mswindowsr   r%   r
   r8   r   _communicate__code__globalsZ_communicate_with_selectZ_communicate_with_pollAttributeErrorr   r   r   r   r
   ,   s,   

c                 C   s"   t | jt }| j|_| j|_|S r   )r   r;   r<   __kwdefaults____defaults__)functionZnew_functionr   r   r   patched_functionw   s    rA   check_output)"r4   systypesr   r1   r   r   Zeventlet.greenr   r   r   Z__patched__Zto_patchr   appendZinjectr<   originalr%   modulesgetZsubprocess_importedplatformr9   r&   	Exceptionr   r
   rA   r   r	   hasattrrB   CalledProcessErrorr   r   r   r   <module>   s6   


K



