404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@3.14.144.101: ~ $
3

�P\��@s�dZddlZddlZddlmZddlmZGdd�de�ZGd	d
�d
e�Z	Gdd�de	�Z
Gd
d�de	�Zdd�ZdddgZ
dS)zEModule implementing the Pool for :mod:``requests_toolbelt.threaded``.�N�)�thread�)�queuec@sneZdZdZdddejfdd�Zdd�Zedd��Z	edd	d
��Z
dd�Zd
d�Zdd�Z
dd�Zdd�ZdS)�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
    Ncs||dkrtj�pd}|dkr$td��|�_tj��_tj��_|�_|pJt	�_
|pTt	�_|�_�fdd�t
�j�D��_dS)Nrz)Number of processes should at least be 1.cs&g|]}tj�j��j�j�j��qS�)rZ
SessionThread�_new_session�
_job_queue�_response_queue�
_exc_queue)�.0�_)�selfr�/usr/lib/python3.6/pool.py�
<listcomp>+sz!Pool.__init__.<locals>.<listcomp>)�multiprocessing�	cpu_count�
ValueErrorr	r�Queuer
rZ
_processes�	_identity�_initializer�_auth�_session�range�_pool)r�	job_queueZinitializerZauth_generatorZ
num_processesZsessionr)rr�__init__s




z
Pool.__init__cCs|j|j|j���S)N)rrr)rrrrr0szPool._new_sessioncKs4tj�}x|D]}|j|j�qW|fd|i|��S)a2Create 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)rr�put�request_kwargs)�cls�
exceptions�kwargsr�excrrr�from_exceptions3s
zPool.from_exceptionscKs^ddi}|j|pi�tj�}x,|D]$}|j�}|jd|i�|j|�q$W|fd|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`
        �methodZGET�urlr)�updaterr�copyr)rZurlsrr!Zrequest_dictrr%Zjobrrr�	from_urlsIs
zPool.from_urlsccs"x|j�}|dkrP|VqWdS)zoIterate over all the exceptions in the pool.

        :returns: Generator of :class:`~ThreadException`
        N)�
get_exception)rr"rrrr bs
zPool.exceptionscCs8y|jj�\}}Wntjk
r(dSXt||�SdS)zSGet an exception from the pool.

        :rtype: :class:`~ThreadException`
        N)r�
get_nowaitr�Empty�ThreadException)r�requestr"rrrr)ms
zPool.get_exceptioncCs8y|jj�\}}Wntjk
r(dSXt||�SdS)zPGet a response from the pool.

        :rtype: :class:`~ThreadResponse`
        N)r
r*rr+�ThreadResponse)rr-�responserrr�get_responseys
zPool.get_responseccs"x|j�}|dkrP|VqWdS)zmIterate over all the responses in the pool.

        :returns: Generator of :class:`~ThreadResponse`
        N)r0)rZresprrr�	responses�s
zPool.responsescCsx|jD]}|j�qWdS)z*Join all the threads to the master thread.N)r�join)rZsession_threadrrr�join_all�sz
Pool.join_all)N)�__name__�
__module__�__qualname__�__doc__�requestsZSessionrr�classmethodr#r(r r)r0r1r3rrrrr	src@seZdZdZdd�ZdS)�ThreadProxyNcCs4tj}||jkr&|||j�}t||�S|||�SdS)z/Proxy attribute accesses to the proxied object.N)�object�__getattribute__�attrs�proxied_attr�getattr)r�attr�getr/rrr�__getattr__�s


zThreadProxy.__getattr__)r4r5r6r>rBrrrrr:�sr:c@s(eZdZdZdZeddg�Zdd�ZdS)r.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()

    r/rcCs||_||_dS)N)rr/)rrr/rrrr�szThreadResponse.__init__N)r4r5r6r7r>�	frozensetr=rrrrrr.�sr.c@s(eZdZdZdZeddg�Zdd�ZdS)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

    �	exceptionrcCs||_||_dS)N)rrD)rrrDrrrr�szThreadException.__init__N)r4r5r6r7r>rCr=rrrrrr,�sr,cCs|S)Nr)Zsession_objrrrr�sr)r7rr8�rZ_compatrr;rr:r.r,r�__all__rrrr�<module>s


Filemanager

Name Type Size Permission Actions
__init__.cpython-36.opt-1.pyc File 3.28 KB 0644
__init__.cpython-36.pyc File 3.28 KB 0644
pool.cpython-36.opt-1.pyc File 6.69 KB 0644
pool.cpython-36.pyc File 6.69 KB 0644
thread.cpython-36.opt-1.pyc File 1.87 KB 0644
thread.cpython-36.pyc File 1.87 KB 0644