관리-도구
편집 파일: payload_streamer.cpython-37.pyc
B �k�a@ � @ s� d Z ddlZddlZddlmZmZmZmZmZ ddl m Z ddlmZm Z dZG dd � d �ZG d d� d�Ze e�G dd � d e��Ze e�G dd� de��ZdS )al Payload implemenation for coroutines as data provider. As a simple case, you can upload data from file:: @aiohttp.streamer async def file_sender(writer, file_name=None): with open(file_name, 'rb') as f: chunk = f.read(2**16) while chunk: await writer.write(chunk) chunk = f.read(2**16) Then you can use `file_sender` like this: async with session.post('http://httpbin.org/post', data=file_sender(file_name='huge_file')) as resp: print(await resp.text()) ..note:: Coroutine must accept `writer` as first argument � N)�Any� Awaitable�Callable�Dict�Tuple� )�AbstractStreamWriter)�Payload�payload_type)�streamerc @ sL e Zd Zeded f eedf eeef dd�dd�Z e dd�dd�ZdS ) �_stream_wrapper.N)�coro�args�kwargs�returnc C s t �|�| _|| _|| _d S )N)�types� coroutiner r r )�selfr r r � r �K/opt/alt/python37/lib64/python3.7/site-packages/aiohttp/payload_streamer.py�__init__$ s z_stream_wrapper.__init__)�writerr c � s | j |f| j�| j�I d H d S )N)r r r )r r r r r �__call__. s z_stream_wrapper.__call__)�__name__� __module__�__qualname__r r r r r �strr r r r r r r r # s r c @ s: e Zd Zeded f dd�dd�Zeeed�dd�ZdS ) r .N)r r c C s t jdtdd� || _d S )Nz5@streamer is deprecated, use async generators instead� )� stacklevel)�warnings�warn�DeprecationWarningr )r r r r r r 3 s zstreamer.__init__)r r r c O s t | j||�S )N)r r )r r r r r r r ; s zstreamer.__call__) r r r r r r r r r r r r r r 2 s r c @ s e Zd Zedd�dd�ZdS )�StreamWrapperPayloadN)r r c � s | � |�I d H d S )N)�_value)r r r r r �writeA s zStreamWrapperPayload.write)r r r r r$ r r r r r"