o
    svXj%  ã                   @   s„   d dl mZ 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eƒZG dd	„ d	ejƒZdS )é    )Úabsolute_importNé   )Ú	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   úV/var/www/html/myproject/venv/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t| ƒ |¡ d S r   )Ú_fdsÚsuperr	   r   )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Ú
connectionr3   ÚosÚWNOHANGr(   r   r,   ÚOSErrorÚEOFError)r   Úflagr3   Útimeoutr   r   r   Úpoll;   s   
ýýz
Popen.poll)r   r   r   Úmethodr
   ÚDupFdr   r   r2   r7   r8   r=   Ú__classcell__r   r   r   r   r	       s    )Ú
__future__r   r#   r7   Ú r   r   r   r   r   Ú__all__Úobjectr
   r	   r   r   r   r   Ú<module>   s    