o
    ¨ÝjÇ  ã                   @   sB  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
 g d¢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ƒ ge¢R Ž  e d¡Zej de¡ZejdkZeeddƒdu rqG 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ƒrše 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   úT/var/www/html/chatgpt/venv/lib/python3.10/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__r   )Ú__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sIe	ejj
jeƒ ƒZ
ze	ejjjeƒ ƒZe	ejjjeƒ ƒZW dS  eyH   Y dS w dS )r
   z-eventlet-friendly version of subprocess.Popenr   c           	      O   s¨   || _ tjj| |dg|¢R i |¤Ž dD ]=}t| |ƒ}|d urQt|ƒtjkrQt|ddƒ}|sD| ¡ r6|d7 }| 	¡ r>|d7 }|dkrDd}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ç{®Gáz„?c              
   C   sŽ   |d ur
t   ¡ | }z"	 |  ¡ }|d ur|W S |d ur't   ¡ |kr't| j|ƒ‚t |¡ q tyF } z|jtjkrAW Y d }~dS ‚ d }~ww )NTr#   )	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
   ,   s2    

þþ
þÿòr
   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>   s8    

K




