Ë
    ±Œjä  ã                   ó–   — d Z ddlZddlZddlmZ ddlmZ  G d„ de«      Z G d	„ d
e«      Z	 G d„ de	«      Z
 G d„ de	«      Zd„ Zg d¢Zy)zEModule implementing the Pool for :mod:``requests_toolbelt.threaded``.é    Né   )Úthreadé   )Úqueuec                   óz   — e Zd ZdZdddej
                  fd„Zd„ Zed„ «       Z	edd„«       Z
d„ Zd„ Zd	„ Zd
„ Zd„ Zy)ÚPoola>  Pool that manages the threads containing sessions.

    :param queue:
        The queue you're expected to use to which you should add items.
    :type queue: queue.Queue
    :param initializer:
        Function used to initialize an instance of ``session``.
    :type initializer: collections.Callable
    :param auth_generator:
        Function used to generate new auth credentials for the session.
    :type auth_generator: collections.Callable
    :param int num_process:
        Number of threads to create.
    :param session:
    :type session: requests.Session
    Nc           	      ó   — |€t        j                  «       xs d}|dk  rt        d«      ‚|| _        t	        j
                  «       | _        t	        j
                  «       | _        || _        |xs t        | _
        |xs t        | _        || _        t        | j                  «      D �cg c]F  }t        j                  | j!                  «       | j                  | j                  | j                  «      ‘ŒH c}| _        y c c}w )Nr   z)Number of processes should at least be 1.)ÚmultiprocessingÚ	cpu_countÚ
ValueErrorÚ
_job_queuer   ÚQueueÚ_response_queueÚ
_exc_queueÚ
_processesÚ	_identityÚ_initializerÚ_authÚ_sessionÚranger   ÚSessionThreadÚ_new_sessionÚ_pool)ÚselfÚ	job_queueÚinitializerÚauth_generatorÚnum_processesÚsessionÚ_s          úi/var/www/html/Fitness-lenito-AI-main/venv/lib/python3.12/site-packages/requests_toolbelt/threaded/pool.pyÚ__init__zPool.__init__   sÕ   € àÐ Ü+×5Ñ5Ó7Ò<¸1ˆMà˜1ÒÜÐHÓIÐIà#ˆŒÜ$Ÿ{™{›}ˆÔÜŸ+™+›-ˆŒØ'ˆŒØ'Ò4¬9ˆÔØ#Ò0¤yˆŒ
ØˆŒô ˜4Ÿ?™?Ô+ó
ñ ,�ô × Ñ  ×!2Ñ!2Ó!4°d·o±oØ!%×!5Ñ!5°t·±õHà+ñ
ˆ�
ùò 
s   Â'AC;c                 ó^   — | j                  | j                  | j                  «       «      «      S ©N)r   r   r   )r   s    r!   r   zPool._new_session0   s"   € Ø�z‰z˜$×+Ñ+¨D¯M©M«OÓ<Ó=Ð=ó    c                 ó‚   — t        j                  «       }|D ]  }|j                  |j                  «       Œ  | dd|i|¤ŽS )a2  Create a :class:`~Pool` from an :class:`~ThreadException`\ s.

        Provided an iterable that provides :class:`~ThreadException` objects,
        this classmethod will generate a new pool to retry the requests that
        caused the exceptions.

        :param exceptions:
            Iterable that returns :class:`~ThreadException`
        :type exceptions: iterable
        :param kwargs:
            Keyword arguments passed to the :class:`~Pool` initializer.
        :returns: An initialized :class:`~Pool` object.
        :rtype: :class:`~Pool`
        r   © )r   r   ÚputÚrequest_kwargs)ÚclsÚ
exceptionsÚkwargsr   Úexcs        r!   Úfrom_exceptionszPool.from_exceptions3   s@   € ô  —K‘K“Mˆ	ÛˆCØ�M‰M˜#×,Ñ,Õ-ð ñ Ñ1˜YÐ1¨&Ñ1Ð1r%   c                 óæ   — ddi}|j                  |xs i «       t        j                  «       }|D ]6  }|j                  «       }|j                  d|i«       |j	                  |«       Œ8  | dd|i|¤ŽS )aë  Create a :class:`~Pool` from an iterable of URLs.

        :param urls:
            Iterable that returns URLs with which we create a pool.
        :type urls: iterable
        :param dict request_kwargs:
            Dictionary of other keyword arguments to provide to the request
            method.
        :param kwargs:
            Keyword arguments passed to the :class:`~Pool` initializer.
        :returns: An initialized :class:`~Pool` object.
        :rtype: :class:`~Pool`
        ÚmethodÚGETÚurlr   r'   )Úupdater   r   Úcopyr(   )r*   Úurlsr)   r,   Úrequest_dictr   r2   Újobs           r!   Ú	from_urlszPool.from_urlsI   su   € ð ! %Ð(ˆØ×Ñ˜NÒ0¨bÔ1Ü—K‘K“Mˆ	ÛˆCØ×#Ñ#Ó%ˆCØ�J‰J˜˜s�|Ô$Ø�M‰M˜#Õð ñ
 Ñ1˜YÐ1¨&Ñ1Ð1r%   c              #   ó<   K  — 	 | j                  «       }|€y|–— Œ­w)zoIterate over all the exceptions in the pool.

        :returns: Generator of :class:`~ThreadException`
        N)Úget_exception)r   r-   s     r!   r+   zPool.exceptionsb   s+   è ø€ ð
 Ø×$Ñ$Ó&ˆCØˆ{ØØŠIð	 ùó   ‚c                 óˆ   — 	 | j                   j                  «       \  }}t        ||«      S # t        j                  $ r Y yw xY w)zSGet an exception from the pool.

        :rtype: :class:`~ThreadException`
        N)r   Ú
get_nowaitÚThreadExceptionr   ÚEmpty)r   Úrequestr-   s      r!   r:   zPool.get_exceptionm   sD   € ð
	1Ø!Ÿ_™_×7Ñ7Ó9‰NˆW�cô # 7¨CÓ0Ð0øô �{‰{ò 	Ùð	úó   ‚+ «AÁ Ac                 óˆ   — 	 | j                   j                  «       \  }}t        ||«      S # t        j                  $ r Y yw xY w)zPGet a response from the pool.

        :rtype: :class:`~ThreadResponse`
        N)r   r=   ÚThreadResponser   r?   )r   r@   Úresponses      r!   Úget_responsezPool.get_responsey   sG   € ð
	5Ø"&×"6Ñ"6×"AÑ"AÓ"CÑˆW�hô " '¨8Ó4Ð4øô �{‰{ò 	Ùð	úrA   c              #   ó<   K  — 	 | j                  «       }|€y|–— Œ­w)zmIterate over all the responses in the pool.

        :returns: Generator of :class:`~ThreadResponse`
        N)rE   )r   Úresps     r!   Ú	responseszPool.responses…   s+   è ø€ ð
 Ø×$Ñ$Ó&ˆDØˆ|ØØŠJð	 ùr;   c                 óF   — | j                   D ]  }|j                  «        Œ y)z*Join all the threads to the master thread.N)r   Újoin)r   Úsession_threads     r!   Újoin_allzPool.join_all�   s   € à"ŸjœjˆNØ×ÑÕ!ñ )r%   r$   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚrequestsÚSessionr"   r   Úclassmethodr.   r8   r+   r:   rE   rH   rL   r'   r%   r!   r   r   	   sd   „ ñð" /3À4Ø#¨X×-=Ñ-=ó
ò*>ð ñ2ó ð2ð* ò2ó ð2ò0	ò
1ò
5ò	ó"r%   r   c                   ó   — e Zd ZdZd„ Zy)ÚThreadProxyNc                 óŽ   — t         j                  }|| j                  vr || | j                  «      }t	        ||«      S  || |«      S )z/Proxy attribute accesses to the proxied object.)ÚobjectÚ__getattribute__ÚattrsÚproxied_attrÚgetattr)r   ÚattrÚgetrD   s       r!   Ú__getattr__zThreadProxy.__getattr__™   sD   € ä×%Ñ%ˆØ�t—z‘zÑ!Ù˜4 ×!2Ñ!2Ó3ˆHÜ˜8 TÓ*Ð*á�t˜T“?Ð"r%   )rM   rN   rO   rZ   r^   r'   r%   r!   rU   rU   –   s   „ Ø€Ló#r%   rU   c                   ó.   — e Zd ZdZdZ eddg«      Zd„ Zy)rC   a>  A wrapper around a requests Response object.

    This will proxy most attribute access actions to the Response object. For
    example, if you wanted the parsed JSON from the response, you might do:

    .. code-block:: python

        thread_response = pool.get_response()
        json = thread_response.json()

    rD   r)   c                 ó    — || _         || _        y r$   )r)   rD   )r   r)   rD   s      r!   r"   zThreadResponse.__init__²   s   € à,ˆÔà ˆ�r%   N©rM   rN   rO   rP   rZ   Ú	frozensetrY   r"   r'   r%   r!   rC   rC   £   s#   „ ñ
ð €LÙÐ'¨Ð4Ó5€Eó!r%   rC   c                   ó.   — e Zd ZdZdZ eddg«      Zd„ Zy)r>   a=  A wrapper around an exception raised during a request.

    This will proxy most attribute access actions to the exception object. For
    example, if you wanted the message from the exception, you might do:

    .. code-block:: python

        thread_exc = pool.get_exception()
        msg = thread_exc.message

    Ú	exceptionr)   c                 ó    — || _         || _        y r$   )r)   rd   )r   r)   rd   s      r!   r"   zThreadException.__init__È   s   € à,ˆÔà"ˆ�r%   Nra   r'   r%   r!   r>   r>   ¹   s#   „ ñ
ð €LÙÐ'¨Ð5Ó6€Eó#r%   r>   c                 ó   — | S r$   r'   )Úsession_objs    r!   r   r   Ï   s   € ØÐr%   )r>   rC   r   )rP   r
   rQ   Ú r   Ú_compatr   rW   r   rU   rC   r>   r   Ú__all__r'   r%   r!   Ú<module>rk      sS   ðÙ KÛ Û å Ý ôJ"ˆ6ô J"ôZ
#�&ô 
#ô!�[ô !ô,#�kô #ò,ò 8�r%   