o
    €¨Êhê  ã                   @   sv   d dl Z d dlZddlmZ ddlmZ ddlmZ ddlmZ ddlmZ dgZG d	d
„ d
ƒZ	G dd„ dej
ƒZ
dS )é    Né   )Ú	reduction)Úcontext)Ú
forkserver)Ú
popen_fork)ÚspawnÚPopenc                   @   s   e Zd Zdd„ Zdd„ ZdS )Ú_DupFdc                 C   s
   || _ d S ©N)Úind)Úselfr   © r   úK/var/www/html/env/lib/python3.10/site-packages/billiard/popen_forkserver.pyÚ__init__   s   
z_DupFd.__init__c                 C   s   t  ¡ | j S r
   )r   Úget_inherited_fdsr   )r   r   r   r   Údetach   s   z_DupFd.detachN)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   r	      s    r	   c                       sB   e Zd ZdZeZ‡ fdd„Zdd„ Zdd„ Ze	j
fdd	„Z‡  ZS )
r   r   c                    s   g | _ tƒ  |¡ d S r
   )Ú_fdsÚsuperr   )r   Úprocess_obj©Ú	__class__r   r   r   "   s   zPopen.__init__c                 C   s   | j  |¡ t| j ƒd S )Nr   )r   ÚappendÚlen)r   Úfdr   r   r   Úduplicate_for_child&   s   zPopen.duplicate_for_childc              	   C   s´   t  |j¡}t ¡ }t | ¡ zt ||¡ t ||¡ W t d ¡ nt d ¡ w t	 
| j¡\| _}tj|ddd��}| | ¡ ¡ W d   ƒ n1 sLw   Y  t	 | j¡| _d S )NÚwbT)Úclosefd)r   Úget_preparation_dataÚ_nameÚioÚBytesIOr   Úset_spawning_popenr   Údumpr   Úconnect_to_new_processr   ÚsentinelÚopenÚwriteÚ	getbufferÚread_unsignedÚpid)r   r   Ú	prep_dataÚbufÚwÚfr   r   r   Ú_launch*   s   
ÿzPopen._launchc              	   C   sx   | j d u r9ddlm} |tjkrdnd }|| jg|ƒsd S zt | j¡| _ W | j S  tt	fy8   d| _ Y | j S w | j S )Nr   )Úwaitr   éÿ   )
Ú
returncodeÚ
connectionr2   ÚosÚWNOHANGr'   r   r+   ÚOSErrorÚEOFError)r   Úflagr2   Útimeoutr   r   r   Úpoll9   s   
ýýz
Popen.poll)r   r   r   Úmethodr	   ÚDupFdr   r   r1   r6   r7   r<   Ú__classcell__r   r   r   r   r      s    )r"   r6   Ú r   r   r   r   r   Ú__all__r	   r   r   r   r   r   Ú<module>   s    