o
    ‘i  ã                   @   s@   d dl Zd dlmZ ddlmZ dd„ ZG dd„ dejjƒZdS )é    Né   )ÚSimpleQueuec                  O   s&   dd l }tjj| i |¤Ž | ¡  d S )Nr   )ÚgcÚmultiprocessingÚpoolZworkerZcollect)ÚargsÚkwargsr   © r	   úi/var/www/html/eduruby.in/lip-sync/lip-sync-env/lib/python3.10/site-packages/torch/multiprocessing/pool.pyÚclean_worker   s   r   c                   @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚPoolzªPool implementation which uses our version of SimpleQueue.
    This lets us pass tensors in shared memory across processes instead of
    serializing the underlying data.c                 C   s,   t ƒ | _t ƒ | _| jjj| _| jjj| _d S )N)	r   Ú_inqueueÚ	_outqueueZ_writerÚsendZ
_quick_putÚ_readerÚrecvZ
_quick_get)Úselfr	   r	   r
   Ú_setup_queues   s   zPool._setup_queuesc                 C   sŽ   t | jt| jƒ ƒD ]:}| j| j| j| j| jf}t	| dƒr#|| j
f7 }| jt|d}| j |¡ |j dd¡|_d|_| ¡  t d¡ q
dS )z€Bring the number of pool processes up to the specified number,
        for use after reaping workers which have exited.
        Ú_wrap_exception)Útargetr   ÚProcessZ
PoolWorkerTzadded workerN)ÚrangeZ
_processesÚlenÚ_poolr   r   Z_initializerZ	_initargsZ_maxtasksperchildÚhasattrr   r   r   ÚappendÚnameÚreplaceÚdaemonÚstartÚutilÚdebug)r   Úir   Úwr	   r	   r
   Ú_repopulate_pool   s    û
ðzPool._repopulate_poolN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r$   r	   r	   r	   r
   r      s    r   )	Zmultiprocessing.poolr   Zmultiprocessing.utilr    Úqueuer   r   r   r   r	   r	   r	   r
   Ú<module>   s
    
