Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.62 (Unix) OpenSSL/1.0.2k-fips
System : Linux server1.richineiserver.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User : fdshops ( 1003)
PHP Version : 8.2.21
Disable Function : NONE
Directory :  /lib/python2.7/site-packages/requests_toolbelt/threaded/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python2.7/site-packages/requests_toolbelt/threaded/pool.pyc
�
ӵ Yc@s�dZddlZddlZddlmZddlmZdefd��YZd	efd
��YZ	de	fd��YZ
d
e	fd��YZd�Zd
ddgZ
dS(sEModule implementing the Pool for :mod:``requests_toolbelt.threaded``.i����Ni(tthreadi(tqueuetPoolcBs}eZdZd
d
d
ejd�Zd�Zed��Z	ed
d��Z
d�Zd�Zd�Z
d�Zd	�ZRS(s>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_threads:
        Number of threads to create.
    :param session:
    :type session: requests.Session
    c
Cs�|dkr!tj�pd}n|dkr<td��n||_tj�|_tj�|_||_	|put
|_|p�t
|_||_
gt|j	�D]-}tj|j�|j|j|j�^q�|_dS(Nis)Number of processes should at least be 1.(tNonetmultiprocessingt	cpu_countt
ValueErrort
_job_queueRtQueuet_response_queuet
_exc_queuet
_processest	_identityt_initializert_autht_sessiontrangeRt
SessionThreadt_new_sessiont_pool(tselft	job_queuetinitializertauth_generatort
num_processestsessiont_((sC/usr/lib/python2.7/site-packages/requests_toolbelt/threaded/pool.pyt__init__s			cCs|j|j|j���S(N(RR
R(R((sC/usr/lib/python2.7/site-packages/requests_toolbelt/threaded/pool.pyR0scKs=tj�}x|D]}|j|j�qW|d||�S(s2Create 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(RRtputtrequest_kwargs(tclst
exceptionstkwargsRtexc((sC/usr/lib/python2.7/site-packages/requests_toolbelt/threaded/pool.pytfrom_exceptions3s
cKszidd6}|j|pi�tj�}x;|D]3}|j�}|ji|d6�|j|�q3W|d||�S(s�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`
        tGETtmethodturlR(tupdateRRtcopyR(RturlsRR trequest_dictRR%tjob((sC/usr/lib/python2.7/site-packages/requests_toolbelt/threaded/pool.pyt	from_urlsIs

ccs2x+tr-|j�}|dkr%Pn|VqWdS(soIterate over all the exceptions in the pool.

        :returns: Generator of :class:`~ThreadException`
        N(tTruet
get_exceptionR(RR!((sC/usr/lib/python2.7/site-packages/requests_toolbelt/threaded/pool.pyRbs
	cCsBy|jj�\}}Wntjk
r0dSXt||�SdS(sSGet an exception from the pool.

        :rtype: :class:`~ThreadException`
        N(R
t
get_nowaitRtEmptyRtThreadException(RtrequestR!((sC/usr/lib/python2.7/site-packages/requests_toolbelt/threaded/pool.pyR-ms
cCsBy|jj�\}}Wntjk
r0dSXt||�SdS(sPGet a response from the pool.

        :rtype: :class:`~ThreadResponse`
        N(R	R.RR/RtThreadResponse(RR1tresponse((sC/usr/lib/python2.7/site-packages/requests_toolbelt/threaded/pool.pytget_responseys
ccs2x+tr-|j�}|dkr%Pn|VqWdS(smIterate over all the responses in the pool.

        :returns: Generator of :class:`~ThreadResponse`
        N(R,R4R(Rtresp((sC/usr/lib/python2.7/site-packages/requests_toolbelt/threaded/pool.pyt	responses�s
	cCs"x|jD]}|j�q
WdS(s*Join all the threads to the master thread.N(Rtjoin(Rtsession_thread((sC/usr/lib/python2.7/site-packages/requests_toolbelt/threaded/pool.pytjoin_all�sN(t__name__t
__module__t__doc__RtrequeststSessionRRtclassmethodR"R+RR-R4R6R9(((sC/usr/lib/python2.7/site-packages/requests_toolbelt/threaded/pool.pyR	s					tThreadProxycBseZdZd�ZRS(cCsHtj}||jkr7|||j�}t||�S|||�SdS(s/Proxy attribute accesses to the proxied object.N(tobjectt__getattribute__tattrstproxied_attrtgetattr(RtattrtgetR3((sC/usr/lib/python2.7/site-packages/requests_toolbelt/threaded/pool.pyt__getattr__�s
	
N(R:R;RRDRH(((sC/usr/lib/python2.7/site-packages/requests_toolbelt/threaded/pool.pyR@�sR2cBs/eZdZdZeddg�Zd�ZRS(s>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()

    R3RcCs||_||_dS(N(RR3(RRR3((sC/usr/lib/python2.7/site-packages/requests_toolbelt/threaded/pool.pyR�s	(R:R;R<RDt	frozensetRCR(((sC/usr/lib/python2.7/site-packages/requests_toolbelt/threaded/pool.pyR2�sR0cBs/eZdZdZeddg�Zd�ZRS(s=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

    t	exceptionRcCs||_||_dS(N(RRJ(RRRJ((sC/usr/lib/python2.7/site-packages/requests_toolbelt/threaded/pool.pyR�s	(R:R;R<RDRIRCR(((sC/usr/lib/python2.7/site-packages/requests_toolbelt/threaded/pool.pyR0�scCs|S(N((tsession_obj((sC/usr/lib/python2.7/site-packages/requests_toolbelt/threaded/pool.pyR�s(R<RR=tRt_compatRRARR@R2R0Rt__all__(((sC/usr/lib/python2.7/site-packages/requests_toolbelt/threaded/pool.pyt<module>s�
	

Spamworldpro Mini