/usr/share/cagefs-skeleton/opt/cloudlinux/venv/lib/python3.11/site-packages/aiohttp
""" Payload implementation 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 """ import types import warnings from typing import Any, Awaitable, Callable, Dict, Tuple from .abc import AbstractStreamWriter from .payload import Payload, payload_type __all__ = ("streamer",) class _stream_wrapper: def __init__( self, coro: Callable[..., Awaitable[None]], args: Tuple[Any, ...], kwargs: Dict[str, Any], ) -> None: self.coro = types.coroutine(coro) self.args = args self.kwargs = kwargs async def __call__(self, writer: AbstractStreamWriter) -> None: await self.coro(writer, *self.args, **self.kwargs) class streamer: def __init__(self, coro: Callable[..., Awaitable[None]]) -> None: warnings.warn( "@streamer is deprecated, use async generators instead", DeprecationWarning, stacklevel=2, ) self.coro = coro def __call__(self, *args: Any, **kwargs: Any) -> _stream_wrapper: return _stream_wrapper(self.coro, args, kwargs) @payload_type(_stream_wrapper) class StreamWrapperPayload(Payload): async def write(self, writer: AbstractStreamWriter) -> None: await self._value(writer) @payload_type(streamer) class StreamPayload(StreamWrapperPayload): def __init__(self, value: Any, *args: Any, **kwargs: Any) -> None: super().__init__(value(), *args, **kwargs) async def write(self, writer: AbstractStreamWriter) -> None: await self._value(writer)
.
Edit
..
Edit
.hash
Edit
__init__.py
Edit
__pycache__
Edit
_cparser.pxd
Edit
_find_header.pxd
Edit
_headers.pxi
Edit
_helpers.cpython-311-x86_64-linux-gnu.so
Edit
_helpers.pyi
Edit
_helpers.pyx
Edit
_http_parser.cpython-311-x86_64-linux-gnu.so
Edit
_http_parser.pyx
Edit
_http_writer.cpython-311-x86_64-linux-gnu.so
Edit
_http_writer.pyx
Edit
_websocket.cpython-311-x86_64-linux-gnu.so
Edit
_websocket.pyx
Edit
abc.py
Edit
base_protocol.py
Edit
client.py
Edit
client_exceptions.py
Edit
client_proto.py
Edit
client_reqrep.py
Edit
client_ws.py
Edit
compression_utils.py
Edit
connector.py
Edit
cookiejar.py
Edit
formdata.py
Edit
hdrs.py
Edit
helpers.py
Edit
http.py
Edit
http_exceptions.py
Edit
http_parser.py
Edit
http_websocket.py
Edit
http_writer.py
Edit
locks.py
Edit
log.py
Edit
multipart.py
Edit
payload.py
Edit
payload_streamer.py
Edit
py.typed
Edit
pytest_plugin.py
Edit
resolver.py
Edit
streams.py
Edit
tcp_helpers.py
Edit
test_utils.py
Edit
tracing.py
Edit
typedefs.py
Edit
web.py
Edit
web_app.py
Edit
web_exceptions.py
Edit
web_fileresponse.py
Edit
web_log.py
Edit
web_middlewares.py
Edit
web_protocol.py
Edit
web_request.py
Edit
web_response.py
Edit
web_routedef.py
Edit
web_runner.py
Edit
web_server.py
Edit
web_urldispatcher.py
Edit
web_ws.py
Edit
worker.py
Edit