§
    sŠtjä  ã                   ó°   — 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dS )zEModule implementing the Pool for :mod:``requests_toolbelt.threaded``.é    Né   )Úthreadé   )Úqueuec                   ó~   — 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dS )Ú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                 ól  ‡ — |€t          j        ¦   «         pd}|dk     rt          d¦  «        ‚|‰ _        t	          j        ¦   «         ‰ _        t	          j        ¦   «         ‰ _        |‰ _        |pt          ‰ _
        |pt          ‰ _        |‰ _        ˆ fd„t          ‰ j        ¦  «        D ¦   «         ‰ _        d S )Nr   z)Number of processes should at least be 1.c                 ó€   •— g | ]:}t          j        ‰                     ¦   «         ‰j        ‰j        ‰j        ¦  «        ‘Œ;S © )r   ÚSessionThreadÚ_new_sessionÚ
_job_queueÚ_response_queueÚ
_exc_queue)Ú.0Ú_Úselfs     €ú]/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/requests_toolbelt/threaded/pool.pyú
<listcomp>z!Pool.__init__.<locals>.<listcomp>*   sV   ø€ ð 
ð 
ð 
ð õ Ô  ×!2Ò!2Ñ!4Ô!4°d´oØ!%Ô!5°t´ñHô Hð
ð 
ð 
ó    )ÚmultiprocessingÚ	cpu_countÚ
ValueErrorr   r   ÚQueuer   r   Ú
_processesÚ	_identityÚ_initializerÚ_authÚ_sessionÚrangeÚ_pool)r   Ú	job_queueÚinitializerÚauth_generatorÚnum_processesÚsessions   `     r   Ú__init__zPool.__init__   s¹   ø€ àÐ Ý+Ô5Ñ7Ô7Ð<¸1ˆMà˜1ÒÐÝÐHÑIÔIÐIà#ˆŒÝ$œ{™}œ}ˆÔÝœ+™-œ-ˆŒØ'ˆŒØ'Ð4­9ˆÔØ#Ð0¥yˆŒ
ØˆŒð
ð 
ð 
ð 
õ ˜4œ?Ñ+Ô+ð
ñ 
ô 
ˆŒ
ˆ
ˆ
r   c                 óv   — |                       |                      |                      ¦   «         ¦  «        ¦  «        S ©N)r   r   r   )r   s    r   r   zPool._new_session0   s*   € Ø�zŠz˜$×+Ò+¨D¯MªM©O¬OÑ<Ô<Ñ=Ô=Ð=r   c                 óz   — t          j        ¦   «         }|D ]}|                     |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   r   ÚputÚrequest_kwargs)ÚclsÚ
exceptionsÚkwargsr"   Úexcs        r   Úfrom_exceptionszPool.from_exceptions3   sQ   € õ  ”K‘M”Mˆ	Øð 	.ð 	.ˆCØ�MŠM˜#Ô,Ñ-Ô-Ð-Ð-àˆsÐ1Ð1˜YÐ1¨&Ð1Ð1Ð1r   c                 óü   — ddi}|                      |pi ¦  «         t          j        ¦   «         }|D ]B}|                     ¦   «         }|                      d|i¦  «         |                     |¦  «         ŒC | 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"   r5   Újobs           r   Ú	from_urlszPool.from_urlsI   s˜   € ð ! %Ð(ˆØ×Ò˜NÐ0¨bÑ1Ô1Ð1Ý”K‘M”Mˆ	Øð 	ð 	ˆCØ×#Ò#Ñ%Ô%ˆCØ�JŠJ˜˜s�|Ñ$Ô$Ð$Ø�MŠM˜#ÑÔÐÐàˆsÐ1Ð1˜YÐ1¨&Ð1Ð1Ð1r   c              #   óB   K  — 	 |                       ¦   «         }|€dS |V — Œ)zoIterate over all the exceptions in the pool.

        :returns: Generator of :class:`~ThreadException`
        TN)Úget_exception)r   r0   s     r   r.   zPool.exceptionsb   s4   è è € ð
	Ø×$Ò$Ñ&Ô&ˆCØˆ{Ø�ØˆIˆIˆIð		r   c                 óˆ   — 	 | j                              ¦   «         \  }}t          ||¦  «        S # t          j        $ r Y dS w xY w)zSGet an exception from the pool.

        :rtype: :class:`~ThreadException`
        N)r   Ú
get_nowaitÚThreadExceptionr   ÚEmpty)r   Úrequestr0   s      r   r=   zPool.get_exceptionm   sV   € ð
	1Ø!œ_×7Ò7Ñ9Ô9‰NˆW�cõ # 7¨CÑ0Ô0Ð0øõ Œ{ð 	ð 	ð 	Ø�4�4ð	øøøó   ‚. ®AÁ Ac                 óˆ   — 	 | j                              ¦   «         \  }}t          ||¦  «        S # t          j        $ r Y dS w xY w)zPGet a response from the pool.

        :rtype: :class:`~ThreadResponse`
        N)r   r?   ÚThreadResponser   rA   )r   rB   Úresponses      r   Úget_responsezPool.get_responsey   sX   € ð
	5Ø"&Ô"6×"AÒ"AÑ"CÔ"CÑˆW�hõ " '¨8Ñ4Ô4Ð4øõ Œ{ð 	ð 	ð 	Ø�4�4ð	øøørC   c              #   óB   K  — 	 |                       ¦   «         }|€dS |V — Œ)zmIterate over all the responses in the pool.

        :returns: Generator of :class:`~ThreadResponse`
        TN)rG   )r   Úresps     r   Ú	responseszPool.responses…   s4   è è € ð
	Ø×$Ò$Ñ&Ô&ˆDØˆ|Ø�ØˆJˆJˆJð		r   c                 óB   — | j         D ]}|                     ¦   «          ŒdS )z*Join all the threads to the master thread.N)r!   Újoin)r   Úsession_threads     r   Újoin_allzPool.join_all�   s2   € à"œjð 	"ð 	"ˆNØ×ÒÑ!Ô!Ð!Ð!ð	"ð 	"r   r)   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚrequestsÚSessionr'   r   Úclassmethodr1   r;   r.   r=   rG   rJ   rN   r   r   r   r   r   	   sÖ   € € € € € ðð ð" /3À4Ø#¨XÔ-=ð
ð 
ð 
ð 
ð*>ð >ð >ð ð2ð 2ñ „[ð2ð* ð2ð 2ð 2ñ „[ð2ð0	ð 	ð 	ð
1ð 
1ð 
1ð
5ð 
5ð 
5ð	ð 	ð 	ð"ð "ð "ð "ð "r   r   c                   ó   — e Zd ZdZd„ ZdS )Ú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ÚgetrF   s       r   Ú__getattr__zThreadProxy.__getattr__™   sK   € åÔ%ˆØ�t”zÐ!Ð!Ø�s˜4 Ô!2Ñ3Ô3ˆHÝ˜8 TÑ*Ô*Ð*à�3�t˜T‘?”?Ð"r   )rO   rP   rQ   r\   r`   r   r   r   rW   rW   –   s(   € € € € € Ø€Lð#ð #ð #ð #ð #r   rW   c                   ó6   — e Zd ZdZdZ eddg¦  «        Zd„ ZdS )rE   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()

    rF   r,   c                 ó"   — || _         || _        d S r)   )r,   rF   )r   r,   rF   s      r   r'   zThreadResponse.__init__²   s   € à,ˆÔà ˆŒˆˆr   N©rO   rP   rQ   rR   r\   Ú	frozensetr[   r'   r   r   r   rE   rE   £   sI   € € € € € ð
ð 
ð €LØˆIÐ'¨Ð4Ñ5Ô5€Eð!ð !ð !ð !ð !r   rE   c                   ó6   — e Zd ZdZdZ eddg¦  «        Zd„ ZdS )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                 ó"   — || _         || _        d S r)   )r,   rf   )r   r,   rf   s      r   r'   zThreadException.__init__È   s   € à,ˆÔà"ˆŒˆˆr   Nrc   r   r   r   r@   r@   ¹   sI   € € € € € ð
ð 
ð €LØˆIÐ'¨Ð5Ñ6Ô6€Eð#ð #ð #ð #ð #r   r@   c                 ó   — | S r)   r   )Úsession_objs    r   r   r   Ï   s   € ØÐr   )r@   rE   r   )rR   r   rS   Ú r   Ú_compatr   rY   r   rW   rE   r@   r   Ú__all__r   r   r   ú<module>rm      s  ðØ KÐ KØ Ð Ð Ð Ø €€€à Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð ðJ"ð J"ð J"ð J"ð J"ˆ6ñ J"ô J"ð J"ðZ
#ð 
#ð 
#ð 
#ð 
#�&ñ 
#ô 
#ð 
#ð!ð !ð !ð !ð !�[ñ !ô !ð !ð,#ð #ð #ð #ð #�kñ #ô #ð #ð,ð ð ð 8Ð
7Ð
7€€€r   