HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/local/lib/python3.10/dist-packages/anyio/__pycache__/to_process.cpython-310.pyc
o

���g{%�@s�UddlmZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZmZddl
mZmZddlmZmZmZdd	lmZdd
lmZddlmZddlmZmZdd
lmZmZm Z ddl!m"Z"m#Z#ddl$m%Z%ej&dkr}ddl
m'Z'm(Z(nddl)m'Z'm(Z(dZ*ed�Z+e'd�Z,e"d�Z-de.d<e"d�Z/de.d<e"d�Z0de.d<ddd�d/d&d'�Z1d0d)d*�Z2d1d,d-�Z3e4d.kr�e3�dSdS)2�)�annotationsN)�deque)�Callable)�module_from_spec�spec_from_file_location)�TypeVar�cast�)�current_time�get_async_backend�get_cancelled_exc_class)�BrokenWorkerProcess)�open_process)�CapacityLimiter)�CancelScope�
fail_after)�ByteReceiveStream�ByteSendStream�Process)�RunVar�checkpoint_if_cancelled)�BufferedByteReceiveStream)��)�TypeVarTuple�Unpacki,�T_Retval�PosArgsT�_process_pool_workerszRunVar[set[Process]]�_process_pool_idle_workersz$RunVar[deque[tuple[Process, float]]]�_default_process_limiterzRunVar[CapacityLimiter]F)�cancellable�limiter�func�&Callable[[Unpack[PosArgsT]], T_Retval]�args�Unpack[PosArgsT]r!�boolr"�CapacityLimiter | None�returnc�sZ�d����fdd�}t�IdHtjd||ftjd	�}z
t���t��}WntyEt��t	�}t���t�|�t
����Ynw|pJt�4IdH��O|r�|�
�\�}�jdur�tt�j��ttt�j���t�}g}	|r�||d
dtkr~n|��\}
}|
����|
�|	�|
�|sstdd
��|	D]	}|��IdHq�Wd�n1s�wYn�����|sStjddtg}t |t!j"t!j"d�IdH�zTtt�j��ttt�j���t#d����$d�IdH}
Wd�n1s�wY|
dk�rt%d|
����t&tj'ddd�}tjdtj(|ftjd	�}||�IdHWn!t%t)�f�y0�t*�yE}z	���t%d�|�d}~ww��+��t|d
��:z)tt,||�IdH�W��v�rj|��t�f�Wd�Wd�IdHS��v�r�|��t�f�ww1�s�wYWd�IdHdS1IdH�s�wYdS)a�
    Call the given function with the given arguments in a worker process.

    If the ``cancellable`` option is enabled and the task waiting for its completion is
    cancelled, the worker process running it will be abruptly terminated using SIGKILL
    (or ``terminateProcess()`` on Windows).

    :param func: a callable
    :param args: positional arguments for the callable
    :param cancellable: ``True`` to allow cancellation of the operation while it's
        running
    :param limiter: capacity limiter to use to limit the total amount of processes
        running (if omitted, the default limiter is used)
    :return: an awaitable that yields the return value of the function.

    �pickled_cmd�bytesr)�objectc�s�z/��|�IdH��dd�IdH}|�d�\}}|dvr%td|������t|��IdH}WnGtyw}z;����z"���t	dd����
�IdHWd�n1sYwYWn	tyhYnwt|t
��rp�t|�d}~wwt�|�}|dkr�t|t�s�J�|�|S)	N�
�2� )�RETURN�	EXCEPTION�-Worker process returned unexpected response: T��shieldr1)�send�
receive_until�split�RuntimeError�receive_exactly�int�
BaseException�discard�killr�aclose�ProcessLookupError�
isinstancerr
�pickle�loads)r*�response�status�length�pickled_response�exc�retval��buffered�process�stdin�workers��;/usr/local/lib/python3.10/dist-packages/anyio/to_process.py�send_raw_command=s>��
�����
z"run_sync.<locals>.send_raw_commandN�run)�protocolrr	Tr3z-uz-m)rL�stdout���READY
r2�__main__�__file__�initz*Error during worker process initialization)r*r+r)r,)-rrA�dumps�HIGHEST_PROTOCOLr�getr�LookupError�setrr�#setup_process_pool_exit_at_shutdown�current_default_process_limiter�pop�
returncoderrrLrrrSr
�WORKER_MAX_IDLE_TIME�popleftr=�remove�appendrr>�sys�
executable�__name__r�
subprocess�PIPEr�receiver
�getattr�modules�pathrr;�addr)r#r!r"r%rP�request�idle_workers�
idle_since�now�killed_processes�process_to_kill�killed_process�command�message�main_module_path�pickledrGrNrIrO�run_sync&s��!

�

�

�	��
�
�
�
�
�
�����

��
F��0�r|rcCs<zt��WStytt��pd�}t�|�|YSw)z�
    Return the capacity limiter that is used by default to limit the number of worker
    processes.

    :return: a capacity limiter object

    �)r r\r]r�os�	cpu_countr^)r"rNrNrOr`�s

�r`�Nonec

Cs�tj}tj}ttj�t_ttjd�t_|j�d�	d}}z
t�	|j�^}}Wnt
y2YdStyE}z|}WYd}~nmd}~ww|dkri|\}}z||�}WnYtyh}z|}WYd}~nJd}~ww|dkr�|\t_}tj
d=|r�tj�|�r�ztd|�}	|	r�|	jr�t|	�}
|	j�|
�|
tj
d<Wnty�}z|}WYd}~nd}~wwz|dur�d}t�|tj�}n	d	}t�|tj�}Wnty�}z|}d}t�|tj�}WYd}~nd}~ww|j�d
|t|�f�|j�|�t|t�r�|�q)N�wrVTrQrYrW�__mp_main__r1r0s%s %d
)rgrLrS�openr~�devnull�buffer�writerA�load�EOFErrorr;rorn�isfiler�loaderr�exec_modulerZr[�lenr@�
SystemExit)
rLrSrH�	exceptionrxr%rGr#rz�spec�mainrDr{rNrNrO�process_worker�sp����



������
�r�rW)
r#r$r%r&r!r'r"r(r)r)r)r)r)r�)5�
__future__rr~rArjrg�collectionsr�collections.abcr�importlib.utilrr�typingrr�_core._eventloopr
rr�_core._exceptionsr
�_core._subprocessesr�_core._synchronizationr�_core._tasksrr�abcrrr�lowlevelrr�streams.bufferedr�version_inforr�typing_extensionsrcrrr�__annotations__rr r|r`r�rirNrNrNrO�<module>sJ
��

;
�