o
    l¨ÊhÆ  ã                   @   sP   d dl Z d dlZddlmZ G dd„ deƒZG dd„ deƒZG dd	„ d	eƒZdS )
é    Né   )ÚBaseProcessc                       s”   e Zd ZdZddddi dddf‡ fdd„	Zedd„ ƒZejd	k r*d
d„ Z	e
dd„ ƒZejdk rFe
dd„ ƒZejdd„ ƒZ‡ fdd„Z‡  ZS ‡  ZS )ÚLokyProcessÚlokyN© Fc	           	         sl   t jdk rtt| ƒj|||||d� || _ntt| ƒj||||||d� |d u r*i n|| _| j| _|| _d S )N©é   r   )ÚgroupÚtargetÚnameÚargsÚkwargs)r	   r
   r   r   r   Údaemon)	ÚsysÚversion_infoÚsuperr   Ú__init__r   ÚenvÚauthkeyÚinit_main_module)	Úselfr	   r
   r   r   r   r   r   r   ©Ú	__class__r   úW/var/www/html/env/lib/python3.10/site-packages/joblib/externals/loky/backend/process.pyr      s   

þ
þ
zLokyProcess.__init__c                 C   s2   t jdkrddlm} || ƒS ddlm} || ƒS )NÚwin32r   )ÚPopen)r   ÚplatformÚpopen_loky_win32r   Úpopen_loky_posix)Úprocess_objr   r   r   r   Ú_Popen!   s
   
ÿzLokyProcess._Popenr   c                 C   sd   ddl m}m} | jdu sJ dƒ‚| jt ¡ ksJ dƒ‚|ƒ  |  | ¡| _| jj| _	|j
 | ¡ dS )z-
            Start child process
            r   )Ú_current_processÚ_cleanupNzcannot start a process twicez:can only start a process object created by current process)Úmultiprocessing.processr!   r"   Ú_popenÚ_parent_pidÚosÚgetpidr    ÚsentinelÚ	_sentinelÚ	_childrenÚadd)r   r!   r"   r   r   r   Ústart*   s   ÿ
zLokyProcess.startc                 C   s    z| j W S  ty   tdƒ‚w )z‡
            Return a file descriptor (Unix) or handle (Windows) suitable for
            waiting for process termination.
            zprocess not started)r)   ÚAttributeErrorÚ
ValueError©r   r   r   r   r(   7   s
   ÿzLokyProcess.sentinel)r   é   c                 C   s   | j S )N)Ú_authkeyr/   r   r   r   r   C   s   zLokyProcess.authkeyc                 C   s   t |ƒ| _dS )z:
            Set authorization key of process
            N)ÚAuthenticationKeyr1   )r   r   r   r   r   r   G   s   c                    s(   ddl m} || jƒ tt| ƒ ¡  d S )Nr   )Úset_start_method)Úcontextr3   Ú_start_methodr   r   Ú
_bootstrap)r   r3   r   r   r   r6   N   s   
zLokyProcess._bootstrap)Ú__name__Ú
__module__Ú__qualname__r5   r   Ústaticmethodr    r   r   r,   Úpropertyr(   r   Úsetterr6   Ú__classcell__r   r   r   r   r      s&    þ






ôr   c                       s.   e Zd ZdZddddi df‡ fdd„	Z‡  ZS )ÚLokyInitMainProcessÚloky_init_mainNr   c              	      s"   t t| ƒj||||||dd� d S )NT)r	   r
   r   r   r   r   r   )r   r>   r   )r   r	   r
   r   r   r   r   r   r   r   r   W   s   


þzLokyInitMainProcess.__init__)r7   r8   r9   r5   r   r=   r   r   r   r   r>   T   s
    ÿr>   c                   @   s   e Zd Zdd„ ZdS )r2   c                 C   s>   ddl m} z|| ƒ W n ty   tdƒ‚w tt| ƒffS )Nr   )Úassert_spawningzGPickling an AuthenticationKey object is disallowed for security reasons)r4   r@   ÚRuntimeErrorÚ	TypeErrorr2   Úbytes)r   r@   r   r   r   Ú
__reduce__c   s   ÿÿzAuthenticationKey.__reduce__N)r7   r8   r9   rD   r   r   r   r   r2   b   s    r2   )r&   r   Úcompatr   r   r>   rC   r2   r   r   r   r   Ú<module>   s   F