o
    h                     @   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poolworkercollect)argskwargsr    r   n/var/www/html/construction_image-detection-poc/venv/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 )PoolzPool 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	_outqueue_writersend
_quick_put_readerrecv
_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 )zIncrease the number of pool processes to the specified number.

        Bring the number of pool processes up to the specified number, for use after
        reaping workers which have exited.
        _wrap_exception)targetr	   Process
PoolWorkerTzadded workerN)range
_processeslen_poolr   r   _initializer	_initargs_maxtasksperchildhasattrr   r   r   appendnamereplacedaemonstartutildebug)r   _r	   wr   r   r   _repopulate_pool   s    
zPool._repopulate_poolN)__name__
__module____qualname____doc__r   r.   r   r   r   r   r      s    r   )	multiprocessing.poolr   multiprocessing.utilr*   queuer   r   r   r   r   r   r   r   <module>   s
    
