ó
    úÞ jä  ã                   ó–   • S r SSKrSSKrSSKJr  SSKJr   " S S\5      r " S	 S
\5      r	 " S S\	5      r
 " S S\	5      rS r/ SQrg)zEModule implementing the Pool for :mod:``requests_toolbelt.threaded``.é    Né   )Úthreadé   )Úqueuec                   ó†   • \ rS rSrSrSSS\R                  4S jrS r\	S 5       r
\	SS j5       rS rS	 rS
 rS rS rSrg)ÚPoolé	   a  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           	      ó(  • Uc  [         R                  " 5       =(       d    SnUS:  a  [        S5      eXl        [        R
                  " 5       U l        [        R
                  " 5       U l        X@l        U=(       d    [        U l
        U=(       d    [        U l        XPl        [        U R                  5       Vs/ sHH  n[        R                  " U R!                  5       U R                  U R                  U R                  5      PMJ     snU l        g s  snf )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          ÚY/var/www/html/gaurav/venv/lib/python3.13/site-packages/requests_toolbelt/threaded/pool.pyÚ__init__Ú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   Â8ADc                 ó^   • U R                  U R                  U R                  5       5      5      $ ©N)r   r   r   )r   s    r"   r   ÚPool._new_session0   s"   € Ø�z‰z˜$×+Ñ+¨D¯M©M«OÓ<Ó=Ð=ó    c                 óˆ   • [         R                  " 5       nU H  nUR                  UR                  5        M      U " SSU0UD6$ )aÚ  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_exceptionsÚPool.from_exceptions3   s@   € ô  —K’K“Mˆ	ÛˆCØ�M‰M˜#×,Ñ,Ö-ñ ñ Ñ1˜YÐ1¨&Ñ1Ð1r(   c                 óö   • SS0nUR                  U=(       d    0 5        [        R                  " 5       nU H7  nUR                  5       nUR                  SU05        UR	                  U5        M9     U " SSU0UD6$ )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   r6   Újobs           r"   Ú	from_urlsÚPool.from_urlsI   su   € ð ! %Ð(ˆØ×Ñ˜N×0¨bÔ1Ü—K’K“Mˆ	ÛˆCØ×#Ñ#Ó%ˆCØ�J‰J˜˜s�|Ô$Ø�M‰M˜#Öñ ñ
 Ñ1˜YÐ1¨&Ñ1Ð1r(   c              #   ó@   #   •  U R                  5       nUc  gUv •  M  7f)z_Iterate over all the exceptions in the pool.

:returns: Generator of :class:`~ThreadException`
N)Úget_exception)r   r0   s     r"   r.   ÚPool.exceptionsb   s*   é € ð
 Ø×$Ñ$Ó&ˆCØ‰{ØØŠIñ	 ùó   ‚c                 ó†   •  U R                   R                  5       u  p[        X5      $ ! [        R                   a     gf = f)zCGet an exception from the pool.

:rtype: :class:`~ThreadException`
N)r   Ú
get_nowaitÚThreadExceptionr   ÚEmpty)r   Úrequestr0   s      r"   r?   ÚPool.get_exceptionm   s@   € ð
	1Ø!Ÿ_™_×7Ñ7Ó9‰NˆWô # 7Ó0Ð0øô �{‰{ó 	Ùð	úó   ‚) ©A ¿A c                 ó†   •  U R                   R                  5       u  p[        X5      $ ! [        R                   a     gf = f)z@Get a response from the pool.

:rtype: :class:`~ThreadResponse`
N)r   rC   ÚThreadResponser   rE   )r   rF   Úresponses      r"   Úget_responseÚPool.get_responsey   sC   € ð
	5Ø"&×"6Ñ"6×"AÑ"AÓ"CÑˆWô " 'Ó4Ð4øô �{‰{ó 	Ùð	úrH   c              #   ó@   #   •  U R                  5       nUc  gUv •  M  7f)z]Iterate over all the responses in the pool.

:returns: Generator of :class:`~ThreadResponse`
N)rL   )r   Úresps     r"   Ú	responsesÚPool.responses…   s*   é € ð
 Ø×$Ñ$Ó&ˆDØ‰|ØØŠJñ	 ùrA   c                 óJ   • U R                    H  nUR                  5         M     g)z*Join all the threads to the master thread.N)r   Újoin)r   Úsession_threads     r"   Újoin_allÚPool.join_all�   s   € à"ŸjœjˆNØ×ÑÖ!ò )r(   )r   r   r   r   r   r   r   r   r&   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__ÚrequestsÚSessionr#   r   Úclassmethodr1   r<   r.   r?   rL   rP   rU   Ú__static_attributes__r*   r(   r"   r   r   	   sd   † ñð" /3À4Ø#¨X×-=Ñ-=ô
ò*>ð ñ2ó ð2ð* ó2ó ð2ò0	ò
1ò
5ò	õ"r(   r   c                   ó   • \ rS rSrSrS rSrg)ÚThreadProxyé–   Nc                 óŠ   • [         R                  nXR                  ;  a  U" X R                  5      n[	        X15      $ U" X5      $ )z/Proxy attribute accesses to the proxied object.)ÚobjectÚ__getattribute__ÚattrsÚproxied_attrÚgetattr)r   ÚattrÚgetrK   s       r"   Ú__getattr__ÚThreadProxy.__getattr__™   s<   € ä×%Ñ%ˆØ—z‘zÓ!Ù˜4×!2Ñ!2Ó3ˆHÜ˜8Ó*Ð*á�t“?Ð"r(   r*   )rW   rX   rY   rZ   rg   rk   r_   r*   r(   r"   ra   ra   –   s   † Ø€Lõ#r(   ra   c                   ó6   • \ rS rSrSrSr\" SS/5      rS rSr	g)rJ   é£   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()

rK   r,   c                 ó   • Xl         X l        g r&   ©r,   rK   )r   r,   rK   s      r"   r#   ÚThreadResponse.__init__²   s   € à,Ôà �r(   rp   N©
rW   rX   rY   rZ   r[   rg   Ú	frozensetrf   r#   r_   r*   r(   r"   rJ   rJ   £   s#   † ñ
ð €LÙÐ'¨Ð4Ó5€Eõ!r(   rJ   c                   ó6   • \ rS rSrSrSr\" SS/5      rS rSr	g)rD   é¹   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                 ó   • Xl         X l        g r&   )r,   rv   )r   r,   rv   s      r"   r#   ÚThreadException.__init__È   s   € à,Ôà"�r(   )rv   r,   Nrr   r*   r(   r"   rD   rD   ¹   s#   † ñ
ð €LÙÐ'¨Ð5Ó6€Eõ#r(   rD   c                 ó   • U $ r&   r*   )Úsession_objs    r"   r   r   Ï   s   € ØÐr(   )rD   rJ   r   )r[   r   r\   Ú r   Ú_compatr   rd   r   ra   rJ   rD   r   Ú__all__r*   r(   r"   Ú<module>r~      sS   ðÙ KÛ Û å Ý ôJ"ˆ6ô J"ôZ
#�&ô 
#ô!�[ô !ô,#�kô #ò,ò 8�r(   