ok

Mini Shell

Direktori : /opt/cloudlinux/venv/lib/python3.11/site-packages/xray/agent/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/xray/agent/__pycache__/executor.cpython-311.pyc

�

��f���l�ddlZddlZddlmZmZddlmZeje��Z	Gd�d��Z
dS)�N)�ThreadPoolExecutor�Future)�BoundedSemaphorec�>�eZdZdZd�Zd�Zd�Zd�Zdd�Zde	fd	�Z
d
S)�BoundedThreadExecutora9
    BoundedExecutor behaves as a ThreadPoolExecutor which will block on
    calls to submit() once the limit given as "bound" work items are queued for
    execution.

    While processing incoming connections, we need two things:
    - the server must be able to process incoming connections
      in multiple threads (one for each client) because we spend some time
      trying to redirect incoming data to our servers
    - the server must have some limit in order not to create new
      threads indefinitely

    This executor has two limits:
    :param max_workers - which limits number of simultaneously running threads
    :param maxqueuesize - which limits number of tasks to wait for the available thread

    When both max_workers and maxqueuesize overflow, .submit function raises
    queue.Full exception.
    c�^�t|���|_t||z��|_dS)N)�max_workers)r�executorr�	semaphore)�self�maxqueuesizer	s   �J/opt/cloudlinux/venv/lib64/python3.11/site-packages/xray/agent/executor.py�__init__zBoundedThreadExecutor.__init__#s,��*�{�C�C�C��
�)�,��*D�E�E�����c��|S�N�)rs r�	__enter__zBoundedThreadExecutor.__enter__'s���rc�.�|���dSr)�shutdown)r�exc_type�exc_val�exc_tbs    r�__exit__zBoundedThreadExecutor.__exit__*s���
�
�����rc��|j�d���}|stj�	|jj|g|�Ri|��}|�|j��|S#|j����xYw)NF)�blocking)	r�acquire�queue�Fullr
�submit�add_done_callback�_on_future_complete�release)r�fn�args�kwargs�success�futures      rr zBoundedThreadExecutor.submit-s����.�(�(�%�(�8�8���	��*��	�)�T�]�)�"�>�t�>�>�>�v�>�>�F�

�$�$�T�%=�>�>�>��M��	��N�"�"�$�$�$����s�A�A9Tc�:�|j�|��dSr)r
r)r�waits  rrzBoundedThreadExecutor.shutdown;s���
���t�$�$�$�$�$r�xc��|j���|���rt�d��dSdS)NzFuture completed with exception)rr#�	exception�logger)rr+s  rr"z)BoundedThreadExecutor._on_future_complete>sN������ � � ��;�;�=�=�	@����>�?�?�?�?�?�	@�	@rN)T)�__name__�
__module__�__qualname__�__doc__rrrr rrr"rrrrrs���������&F�F�F����������%�%�%�%�@�V�@�@�@�@�@�@rr)�loggingr�concurrent.futuresrr�	threadingr�	getLoggerr/r.rrrr�<module>r7s�������
����9�9�9�9�9�9�9�9�&�&�&�&�&�&�	��	�8�	$�	$��3@�3@�3@�3@�3@�3@�3@�3@�3@�3@r

Zerion Mini Shell 1.0