
    ¯wg                     h    d dl Zd dlmZ ddlmZ d Z G d dej                  j                        Zy)    N   )SimpleQueuec                  j    dd l }t        j                  j                  | i | |j	                          y )Nr   )gcmultiprocessingpoolworkercollect)argskwargsr   s      _/home/mcse/projects/flask/flask-venv/lib/python3.12/site-packages/torch/multiprocessing/pool.pyclean_workerr      s)    00 JJL    c                       e Zd ZdZd Zd Zy)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                     t               | _        t               | _        | j                  j                  j                  | _        | j                  j                  j                  | _        y )N)	r   _inqueue	_outqueue_writersend
_quick_put_readerrecv
_quick_get)selfs    r   _setup_queueszPool._setup_queues   sB    #$--//44..0055r   c                    t        | j                  t        | j                        z
        D ]  }| j                  | j
                  | j                  | j                  | j                  f}t        | d      r|| j                  fz  }| j                  t        |      }| j                  j                  |       |j                  j                  dd      |_        d|_        |j#                          t%        j&                  d        y)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   ir   ws       r   _repopulate_poolzPool._repopulate_pool   s     tTZZ89 	'A !!&&D t./--//Lt<AJJa VV^^I|<AFAHGGIJJ~&!	'r   N)__name__
__module____qualname____doc__r   r3    r   r   r   r      s    6'r   r   )	multiprocessing.poolr   multiprocessing.utilr/   queuer   r   r   r   r8   r   r   <module>r<      s+     # #'?$$ #'r   