o
    ;i                     @   s"  d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlmZ d dl	m
Z
mZmZmZmZmZmZmZ d dl	mZmZmZ zd dlZW n eyQ   dZY nw d dlmZ d dlmZ ddlmZmZ dd	lm Z m!Z! dd
l"m#Z# ddl$m%Z%m&Z&m'Z' ddl$m(Z(m)Z) ddl*m+Z+ ddl,m-Z-m.Z.m/Z0m1Z1 ddl2m3Z3m4Z4m5Z5m6Z6 ddl2m7Z7m8Z8m9Z9m:Z: ddl2m;Z;m<Z< ddl=m>Z>m?Z?m@Z@ ddlAmBZBmCZCmDZD ddlEmFZFmGZG ddlEmHZH ddlImJZK erddlLmMZM dZNeOejPjQjRe jSeOejPjTjRe jUeOejPjVjRe jWeOejPjXjRe jYeOejPjZjRe j[eOejPj\jRe j[eOejPj]jRe j[eOejPj^jRe j[iZ_G dd de.Z`G dd de'e( e
e)e(f Z/G dd dejaZbG dd  d ZcG d!d" d"e
e)e(f ZdG d#d$ d$ede)e(f ZeG d%d& d&ede)e(f ZfG d'd( d(ede)e(f ZgG d)d* d*ede)e(f ZhdS )+    N)TracebackType)GenericOptionalUnionTypeListSequenceAnycast)DictTupleTYPE_CHECKING)H2Configuration)	MultiDict   )WrapperDeadlineWrapper)StatusCardinality)Configuration)send_messagerecv_messageStreamIterator)	_RecvType	_SendType)_DispatchChannelEvents)
H2ProtocolAbstractHandlerStreamPeer)Deadline
USER_AGENTdecode_grpc_messageencode_timeout)encode_metadatadecode_metadata_MetadataLike	_Metadata)_STATUS_DETAILS_KEYdecode_bin_value)	GRPCErrorProtocolErrorStreamTerminatedError)GRPC_CONTENT_TYPE	CodecBaseStatusDetailsCodecBase)
ProtoCodecProtoStatusDetailsCodec)_googleapis_available)channels)IReleaseStream200c                   @   sF   e Zd ZdZdedededdfddZdeddfd	d
ZdddZdS )HandlerFstreamheadersrelease_streamreturnNc                 C   s   t d)Nz)Client connection can not accept requestsNotImplementedError)selfr7   r8   r9    r>   B/home/ubuntu/.local/lib/python3.10/site-packages/grpclib/client.pyacceptD   s   zHandler.acceptc                 C   s   d S Nr>   )r=   r7   r>   r>   r?   cancelG   s   zHandler.cancelc                 C   s
   d| _ d S )NT)connection_lostr=   r>   r>   r?   closeJ   s   
zHandler.closer:   N)__name__
__module____qualname__rC   r	   r@   rB   rE   r>   r>   r>   r?   r6   A   s
    r6   c                   @   s  e Zd ZU dZdZdZdZdZdZdZ	dZ
ee ed< eed< ded< dZdZee ed< dZee ed	< dZee ed
< dZdZdddddedededee dee dedee dedee ddfddZ dddeddfddZ!dddededdfd d!Z"dCd"d#Z#d$e$eef ddfd%d&Z%d$e$eef ddfd'd(Z&d$e$eef de'e(ee e)f fd)d*Z*d+e(dee d,e)ddfd-d.Z+dCd/d0Z,dee fd1d2Z-dCd3d4Z.dCd5d6Z/dDd8d9Z0dCd:d;Z1dCd<d=Z2d>eee3  d?ee3 d@ee4 ddfdAdBZ5dS )Er   aM  
    Represents gRPC method call - HTTP/2 request/stream, and everything you
    need to communicate with server in order to get response.

    In order to work directly with stream, you should
    :py:meth:`ServiceMethod.open` request like this:

    .. code-block:: python3

        request = cafe_pb2.LatteOrder(
            size=cafe_pb2.SMALL,
            temperature=70,
            sugar=3,
        )
        async with client.MakeLatte.open() as stream:
            await stream.send_message(request, end=True)
            reply: empty_pb2.Empty = await stream.recv_message()

    FN_trailers_only_streamr4   _release_streaminitial_metadatatrailing_metadatapeerr   )deadlinechannelChannelmethod_namemetadatacardinality	send_type	recv_typecodecstatus_details_codecdispatchrP   r:   c                C   s@   || _ || _|| _|| _|| _|| _|| _|| _|	| _|
| _	d S rA   )
_channel_method_name	_metadata_cardinality
_send_type
_recv_type_codec_status_details_codec	_dispatch	_deadline)r=   rQ   rS   rT   rU   rV   rW   rX   rY   rZ   rP   r>   r>   r?   __init__   s   
zStream.__init__endrg   c          	         sv  | j rtd|r| jjstd| j | j I dH }|jjj	| jd}dd| jj
fd| jfd| jjfg}| jdurK| j }|d	t|f | jjd
krTt}ntd | jj }|dd|fdtff | jj| j| j| j|dI dH \}|t| |j|||jdI dH }|| _|| _| jj | _d| _ |rd| _W d   dS W d   dS 1 sw   Y  dS )a  Coroutine to send request headers with metadata to the server.

        New HTTP/2 stream will be created during this coroutine call.

        .. note:: This coroutine will be called implicitly during first
            :py:meth:`send_message` coroutine call, if not called before
            explicitly.

        :param end: end outgoing stream if there are no messages to send in
            a streaming request
        zRequest is already sentzIUnary request requires a message to be sent before ending outgoing streamN)wrapper)z:methodPOSTz:schemez:pathz
:authorityzgrpc-timeoutproto+)tetrailerscontent-typez
user-agent)rS   rP   content_type)
end_stream
_processorT)_send_request_doner+   r^   client_streaming_wrapperr[   __connect__	processor
connectioncreate_stream_schemer\   
_authorityrd   time_remainingappendr#   ra   __content_subtype__r-   extendr!   rc   send_requestr]   r$   rK   rL   get_peerrO   	_end_done)	r=   rg   protocolr7   r8   timeoutro   rT   r9   r>   r>   r?   r      sb   



("zStream.send_requestmessagec                   s   | j s|  I dH  |}| jjs| jrtdd}| jr!td| jI | j	|I dH \}t	| j
| j|| j|dI dH  d| _|  jd7  _| j
j jd7  _t | j
j_|red| _W d   dS W d   dS 1 spw   Y  dS )a  Coroutine to send message to the server.

        If client sends UNARY request, then you should call this coroutine only
        once. If client sends STREAM request, then you can call this coroutine
        as many times as you need.

        .. warning:: It is important to finally end stream from the client-side
            when you finished sending messages.

        You can do this in two ways:

        - specify ``end=True`` argument while sending last message - and last
          DATA frame will include END_STREAM flag;
        - call :py:meth:`end` coroutine after sending last message - and extra
          HEADERS frame with END_STREAM flag will be sent.

        First approach is preferred, because it doesn't require sending
        additional HTTP/2 frame.
        NzMessage was already sentTzStream is endedrf   r   )rr   r   r^   rs   _send_message_doner+   r   rt   rc   r   rK   ra   r_   _messages_sentrw   messages_senttime	monotoniclast_message_sent)r=   r   rg   rp   r>   r>   r?   r      s0   "zStream.send_messagec                    sX   | j std| jrtd| jjs| jstdd| _dS | j I dH  d| _dS )az  Coroutine to end stream from the client-side.

        It should be used to finally end stream from the client-side when we're
        finished sending messages to the server and stream wasn't closed with
        last DATA frame. See :py:meth:`send_message` for more details.

        HTTP/2 stream will have half-closed (local) state after this coroutine
        call.
        zRequest was not sentzStream was already endedz2Unary request requires a single message to be sentTN)rr   r+   r   r^   rs   r   rK   rg   rD   r>   r>   r?   rg   	  s   

z
Stream.endheaders_mapc                 C   s>   |d }|d ur|t krt|tj}t|d|d S d S )Nz:statuszReceived :status = {!r})_H2_OK_H2_TO_GRPC_STATUS_MAPgetr   UNKNOWNr*   format)r=   r   statusgrpc_statusr>   r>   r?   _raise_for_status%  s   zStream._raise_for_statusc                 C   sb   | d}|d u rttjd|d\}}}|ptj}|tks&|| jjkr/ttjd	|d S )Nrn   zMissing content-type headerrk   zInvalid content-type: {!r})
r   r*   r   r   	partitionr0   r}   r-   ra   r   )r=   r   ro   base_content_type_sub_typer>   r>   r?   _raise_for_content_type,  s   

zStream._raise_for_content_typec                 C   s   | d}|d u rttjdztt|}W n ty'   ttjd|w d\}}|tjurY| d}|d ur>t|}| j	d urY| t
}|d urY| j	||t|d}|||fS )Ngrpc-statuszMissing grpc-status headerzInvalid grpc-status: {!r}NNzgrpc-messageascii)r   r*   r   r   int
ValueErrorr   OKr"   rb   r(   decoder)   encode)r=   r   r   r   r   detailsdetails_binr>   r>   r?   _process_grpc_status<  s.   





zStream._process_grpc_statusr   r   c                 C   s   |t jurt|||d S rA   )r   r   r*   )r=   r   r   r   r>   r>   r?   _raise_for_grpc_statusV  s   
zStream._raise_for_grpc_statusc                    s,  | j std| jrtd| jz | j I dH }d| _t|}| | | | d|v rkd| _	t
tt }| j|I dH \}|| _| |\}}}t|}| jj||||dI dH \}|| _| ||| nt|}| j|I dH \}|| _W d   dS W d   dS 1 sw   Y  dS )a-  Coroutine to wait for headers with initial metadata from the server.

        .. note:: This coroutine will be called implicitly during first
            :py:meth:`recv_message` coroutine call, if not called before
            explicitly.

        May raise :py:class:`~grpclib.exceptions.GRPCError` if server returned
        non-:py:attr:`Status.OK <grpclib.const.Status.OK>` in trailers-only
        response.

        When this coroutine finishes, you can access received initial metadata
        by using :py:attr:`initial_metadata` attribute.
        Request was not sent yetz%Initial metadata was already receivedNTr   r   status_messagestatus_details)rr   r+   _recv_initial_metadata_donert   rK   recv_headersdictr   r   rJ   r
   r'   r   rc   recv_initial_metadatarM   r   r%   recv_trailing_metadatarN   r   )r=   r8   r   imr   r   r   tmr>   r>   r?   r   \  sD   


"zStream.recv_initial_metadatac                    s   | j s|  I dH  | jD t| j| j| jI dH }|durI| j|I dH \}|  jd7  _| jj	 j
d7  _
t | jj	_|W  d   S 	 W d   dS 1 sUw   Y  dS )aV  Coroutine to receive incoming message from the server.

        If server sends UNARY response, then you can call this coroutine only
        once. If server sends STREAM response, then you should call this
        coroutine several times, until it returns None when the server has
        ended the stream. To simplify you code in this case, :py:class:`Stream`
        implements async iterations protocol, so you can use it like this:

        .. code-block:: python3

            async for message in stream:
                do_smth_with(message)

        or even like this:

        .. code-block:: python3

            messages = [msg async for msg in stream]

        HTTP/2 has flow control mechanism, so client will acknowledge received
        DATA frames as a message only after user consumes this coroutine.

        :returns: message
        Nr   )r   r   rt   r   rK   ra   r`   rc   _messages_receivedrw   messages_receivedr   r   last_message_receivedr=   r   r>   r>   r?   r     s    


$zStream.recv_messagec                    s   | j s| jjs| jstd| jstd| jrtd| jr%d| _dS | j: | j	
 I dH }d| _| t|\}}}t|}| jj||||dI dH \}|| _| ||| W d   dS 1 sew   Y  dS )a  Coroutine to wait for trailers with trailing metadata from the
        server.

        .. note:: This coroutine will be called implicitly at exit from
            this call (context manager's exit), if not called before explicitly.

        May raise :py:class:`~grpclib.exceptions.GRPCError` if server returned
        non-:py:attr:`Status.OK <grpclib.const.Status.OK>` in trailers.

        When this coroutine finishes, you can access received trailing metadata
        by using :py:attr:`trailing_metadata` attribute.
        zOutgoing stream was not endedzFInitial metadata was not received before waiting for trailing metadataz&Trailing metadata was already receivedTNr   )r   r^   rs   r   r+   r   _recv_trailing_metadata_donerJ   rt   rK   recv_trailersr   r   r%   rc   r   rN   r   )r=   rm   r   r   r   r   r>   r>   r?   r     s:   

"zStream.recv_trailing_metadatac                    s`   | j std| jrtd| j | j I dH  d| _W d   dS 1 s)w   Y  dS )zCoroutine to cancel this request/stream.

        Client will send RST_STREAM frame to the server, so it will be
        explicitly informed that there is nothing to expect from the client
        regarding this request/stream.
        r   zStream was already cancelledNT)rr   r+   _cancel_donert   rK   resetrD   r>   r>   r?   rB     s   "zStream.cancelStream[_SendType, _RecvType]c                    sX   | j d u rt | _nt | _| j| j | _| j  | j jd7  _t	
 | j_| S )Nr   )rd   r   rt   r   start_wrapper_ctx	__enter__r[   _calls_startedr   r   _last_call_startedrD   r>   r>   r?   
__aenter__  s   


zStream.__aenter__c                    sL   | j s | jj s"| js|  I d H  | js$|  I d H  d S d S d S d S rA   )r   rK   
_transport
is_closingr   r   r   r   rD   r>   r>   r?   _maybe_finish  s   
zStream._maybe_finishc                 C   s   | j jd ur| t| j j | j jd ur*| t| j j\}}}| ||| d S | j jd urKt| j j}d|v rM| |\}}}| ||| d S d S d S )Nr   )rK   r8   r   r   rm   r   r   )r=   r   r   r   r   r>   r>   r?   _maybe_raise  s    


zStream._maybe_raiseexc_typeexc_valexc_tbc                    s>  | j sd S zhd}|d u r)z	|  I d H  W n ty(   t \}}}d}Y nw t|tr2|   |r<|d us:J |W | jj	rF| j
  |   | jd urW| j||| |d u re| j jd7  _d S | j jd7  _d S | jj	rx| j
  |   | jd ur| j||| |d u r| j jd7  _w | j jd7  _w )NFTr   )rr   r   	Exceptionsysexc_info
isinstancer,   r   rK   closablereset_nowaitrL   r   __exit__r[   _calls_succeeded_calls_failed)r=   r   r   r   reraiser>   r>   r?   	__aexit__  sD   




zStream.__aexit__rF   )r:   r   )6rG   rH   rI   __doc__rr   r   r   r   r   r   rJ   r   bool__annotations___Streamr   rM   r'   rN   rO   r   r   r   strr   r   r   r   r.   r/   r   r    re   r   r   rg   r   r   r   r   r   r	   r   r   r   r   r   rB   r   r   r   BaseExceptionr   r   r>   r>   r>   r?   r   N   s   
 	

B

1



4
(
/




r   c                   @   s   e Zd ZdZdZdZdZdS )_ChannelStater            N)rG   rH   rI   IDLE
CONNECTINGREADYTRANSIENT_FAILUREr>   r>   r>   r?   r   B  s
    r   c                   @   s  e Zd ZU dZdZdZdZdZdZe	e
 ed< 		d8dddddddde	e de	e de	ej d	e	e d
e	e de	e dededdf de	e fddZdefddZdefddZdefddZedefddZdefddZddde	d ddfdd Zdededefd!d"Zdddd#d$ed%ed&e e! d'e e" d(e	e
 d)e	e# d*e	e$ de%e!e"f fd+d,Z&d9d-d.Z'd9d/d0Z(d:d1d2Z)d3e	e e*  d4e	e* d5e	e+ ddfd6d7Z,dS );rR   a  
    Represents a connection to the server, which can be used with generated
    stub classes to perform gRPC calls.

    .. code-block:: python3

        channel = Channel()
        client = cafe_grpc.CoffeeMachineStub(channel)

        ...

        request = cafe_pb2.LatteOrder(
            size=cafe_pb2.SMALL,
            temperature=70,
            sugar=3,
        )
        reply: empty_pb2.Empty = await client.MakeLatte(request)

        ...

        channel.close()
    Nr   r   )looppathrX   rY   sslconfighostportr   r   rX   rY   r   z_ssl.SSLContextz_ssl.DefaultVerifyPathsr   c          	      C   sd  |dur|dus|durt d|du rd}|du rd}tdu r)|dur(tdn|du r2|  }nt|tjr>| j|d}|du rOt }|du rOt rOt }|rYt	j
dtd	d
 || _|| _|pdt | _|| _|| _|| _|prd| _| jrydnd| _| | j| j| _tddddddd| _t | _tj| _|du rt n|}| | _ t! | _"t#$|  dS )a4  Initialize connection to the server

        :param host: server host name.

        :param port: server port number.

        :param loop: (deprecated) asyncio-compatible event loop

        :param path: server socket path. If specified, host and port should be
            omitted (must be None).

        :param codec: instance of a codec to encode and decode messages,
            if omitted ``ProtoCodec`` is used by default

        :param status_details_codec: instance of a status details codec to
            decode error details in a trailing metadata, if omitted
            ``ProtoStatusDetailsCodec`` is used by default

        :param ssl: ``True`` or :py:class:`~python:ssl.SSLContext` object or
            ``ssl.DefaultVerifyPaths`` object; if ``True``, default SSL context
            is used.
        NzJThe 'path' parameter can not be used with the 'host' or 'port' parameters.z	127.0.0.1i  zSSL is not supportedTverify_pathszHThe loop argument is deprecated and scheduled for removal in grpclib 0.5r   )
stacklevelhttpshttpr   F)client_sideheader_encodingvalidate_inbound_headersvalidate_outbound_headersnormalize_inbound_headersnormalize_outbound_headers)%r   _sslRuntimeError_get_default_ssl_contextr   DefaultVerifyPathsr0   r2   r1   warningswarnDeprecationWarning_host_portasyncioget_event_loop_loop_pathra   rb   ry   _get_authorityrz   r   
_h2_configLock_connect_lockr   r   _stater   __for_client___configr   __dispatch__	_channelsadd)	r=   r   r   r   r   rX   rY   r   r   r>   r>   r?   re   h  sZ   $



zChannel.__init__r:   c                 C   s   d | j| j| jS )Nz#Channel({!r}, {!r}, ..., path={!r}))r   r   r   r   rD   r>   r>   r?   __repr__  s   zChannel.__repr__c                 C   s   t t | j| jS rA   )r   r6   r  r   rD   r>   r>   r?   _protocol_factory  s   zChannel._protocol_factoryc                    s   | j d ur#| jj| j| j | j| jd ur| jjnd dI d H \}}|S | jj| j| j| j	| j| jd ur7| jjnd dI d H \}}|S )N)r   server_hostname)
r   r   create_unix_connectionr  r   r  ssl_target_name_overridecreate_connectionr   r   )r=   r   r   r>   r>   r?   _create_connection  s*   



zChannel._create_connectionc                 C   s   | j d uo
| j jj S rA   )	_protocolhandlerrC   rD   r>   r>   r?   
_connected  s   

zChannel._connectedc              	      s   | j sC| j4 I d H - tj| _| j s.z
|  I d H | _W n ty)   tj| _ w tj	| _W d   I d H  n1 I d H s>w   Y  t
t| jS rA   )r  r   r   r   r  r  r  r   r   r   r
   r   rD   r>   r>   r?   ru     s   
(
zChannel.__connect__r   r   c                C   s~   |d ur|j }|j}nzdd l}W n ty   d }Y nw | }d }tjtjj||d}tj	j
|_|d |dg |S )Nr   )purposecafilecapathz3ECDHE+AESGCM:ECDHE+CHACHA20:DHE+AESGCM:DHE+CHACHA20h2)r  r  certifiImportErrorwherer   create_default_contextPurposeSERVER_AUTH
TLSVersionTLSv1_2minimum_versionset_ciphersset_alpn_protocols)r=   r   r  r  r  ctxr>   r>   r?   r     s&   

z Channel._get_default_ssl_contextc                 C   s<   zt |}W n
 t jy   Y nw d| d}d||S )N[]z{}:{})	ipaddressIPv6AddressAddressValueErrorr   )r=   r   r   ipv6_addressr>   r>   r?   r     s   zChannel._get_authority)r   rP   rT   namerU   request_type
reply_typer   rP   rT   c                C   sp   |d ur|d u rt |}n|d ur|d urtt ||}ttt|p$d}t| |||||| j| j| j	|d
S )Nr>   )rX   rY   rZ   rP   )
r    from_timeoutminr
   r'   r   r   ra   rb   r  )r=   r'  rU   r(  r)  r   rP   rT   r>   r>   r?   request  s   
zChannel.requestc                 C   s&   | j dur| j j  | ` tj| _dS )z)Closes connection to the server.
        N)r  rv   rE   r   r   r  rD   r>   r>   r?   rE   .  s   
zChannel.closec                 C   sN   | j d ur%d| }t|t | j rd S |   | jd|i d S d S )NzUnclosed connection: {!r}r   )	r  r   r   r   ResourceWarningr   	is_closedrE   call_exception_handlerr   r>   r>   r?   __del__6  s   


zChannel.__del__c                    s   | S rA   r>   rD   r>   r>   r?   r   @  s   zChannel.__aenter__r   r   r   c                    s   |    d S rA   )rE   )r=   r   r   r   r>   r>   r?   r   C  s   zChannel.__aexit__r   rF   )r:   rR   )-rG   rH   rI   r   r  r   r   r   r   r   floatr   r   r   r   AbstractEventLoopr.   r/   r   r   r   re   r  r   r  r  propertyr  ru   r   r   r   r   r   r   r    r&   r   r,  rE   r0  r   r   r   r   r>   r>   r>   r?   rR   I  s   
 	

Z
	







rR   c                	   @   sr   e Zd ZdZdededee dee fddZ	e
defd	d
Zddddee dee deeef fddZdS )ServiceMethodz.
    Base class for all gRPC method types
    rQ   r'  r(  r)  c                 C   s   || _ || _|| _|| _d S rA   )rQ   r'  r(  r)  )r=   rQ   r'  r(  r)  r>   r>   r?   re   Q  s   
zServiceMethod.__init__r:   c                 C   s   t rA   r;   rD   r>   r>   r?   r^   ]  s   zServiceMethod._cardinalityNr   rT   r   rT   c                C   s    | j j| j| j| j| j||dS )a6  Creates and returns :py:class:`Stream` object to perform request
        to the server.

        Nothing will happen to the current underlying HTTP/2 connection during
        this method call. It just initializes :py:class:`Stream` object for you.
        Actual request will be sent only during :py:meth:`Stream.send_request`
        or :py:meth:`Stream.send_message` coroutine call.

        :param float timeout: request timeout (seconds)
        :param metadata: custom request metadata, dict or list of pairs
        :return: :py:class:`Stream` object
        r5  )rQ   r,  r'  r^   r(  r)  )r=   r   rT   r>   r>   r?   opena  s   zServiceMethod.open)rG   rH   rI   r   rR   r   r   r   r   re   r3  r   r^   r   r1  r&   r   r6  r>   r>   r>   r?   r4  L  s,    

r4  c                	   @   s@   e Zd ZdZejZddddedee	 dee
 defdd	ZdS )
UnaryUnaryMethodzi
    Represents UNARY-UNARY gRPC method type.

    .. automethod:: __call__
    .. automethod:: open
    Nr5  r   r   rT   r:   c             	      sv   | j ||d4 I dH }|j|ddI dH  | I dH }W d  I dH  n1 I dH s.w   Y  |dus9J |S )zCoroutine to perform defined call.

        :param message: message
        :param float timeout: request timeout (seconds)
        :param metadata: custom request metadata, dict or list of pairs
        :return: message
        r5  NTrf   )r6  r   r   )r=   r   r   rT   r7   replyr>   r>   r?   __call__  s   (zUnaryUnaryMethod.__call__)rG   rH   rI   r   r   UNARY_UNARYr^   r   r   r1  r&   r   r9  r>   r>   r>   r?   r7  x  s    r7  c                
   @   sD   e Zd ZdZejZddddedee	 dee
 dee fdd	ZdS )
UnaryStreamMethodzj
    Represents UNARY-STREAM gRPC method type.

    .. automethod:: __call__
    .. automethod:: open
    Nr5  r   r   rT   r:   c             	      sp   | j ||d4 I dH }|j|ddI dH  dd |2 I dH W  d  I dH  S 1 I dH s1w   Y  dS )zCoroutine to perform defined call.

        :param message: message
        :param float timeout: request timeout (seconds)
        :param metadata: custom request metadata, dict or list of pairs
        :return: sequence of messages
        r5  NTrf   c                       g | z3 d H W }|q6 S rA   r>   .0r   r>   r>   r?   
<listcomp>      z.UnaryStreamMethod.__call__.<locals>.<listcomp>)r6  r   )r=   r   r   rT   r7   r>   r>   r?   r9    s
   0zUnaryStreamMethod.__call__)rG   rH   rI   r   r   UNARY_STREAMr^   r   r   r1  r&   r   r   r9  r>   r>   r>   r?   r;    s    r;  c                	   @   sD   e Zd ZdZejZddddee de	e
 de	e defdd	ZdS )
StreamUnaryMethodzj
    Represents STREAM-UNARY gRPC method type.

    .. automethod:: __call__
    .. automethod:: open
    Nr5  messagesr   rT   r:   c             	      s   | j ||d4 I dH ;}|dd D ]
}||I dH  q|r-|j|d ddI dH  n	|jddI dH  | I dH }W d  I dH  n1 I dH sMw   Y  |dusXJ |S )zCoroutine to perform defined call.

        :param messages: sequence of messages
        :param float timeout: request timeout (seconds)
        :param metadata: custom request metadata, dict or list of pairs
        :return: message
        r5  NTrf   )r6  r   r   r   )r=   rC  r   rT   r7   r   r8  r>   r>   r?   r9    s   (zStreamUnaryMethod.__call__)rG   rH   rI   r   r   STREAM_UNARYr^   r   r   r   r1  r&   r   r9  r>   r>   r>   r?   rB    s    rB  c                
   @   sH   e Zd ZdZejZddddee de	e
 de	e dee fdd	ZdS )
StreamStreamMethodzk
    Represents STREAM-STREAM gRPC method type.

    .. automethod:: __call__
    .. automethod:: open
    Nr5  rC  r   rT   r:   c             	      s   | j ||d4 I dH >}|dd D ]
}||I dH  q|r-|j|d ddI dH  n	|jddI dH  dd |2 I dH W  d  I dH  S 1 I dH sPw   Y  dS )a   Coroutine to perform defined call.

        :param messages: sequence of messages
        :param float timeout: request timeout (seconds)
        :param metadata: custom request metadata, dict or list of pairs
        :return: sequence of messages
        r5  NrD  Trf   c                    r<  rA   r>   r=  r>   r>   r?   r?    r@  z/StreamStreamMethod.__call__.<locals>.<listcomp>)r6  r   r   )r=   rC  r   rT   r7   r   r>   r>   r?   r9    s   0zStreamStreamMethod.__call__)rG   rH   rI   r   r   STREAM_STREAMr^   r   r   r   r1  r&   r   r   r9  r>   r>   r>   r?   rF    s    rF  )ir   enumr   r   r   r   r#  typesr   typingr   r   r   r   r   r   r	   r
   r   r   r   r   r   r  	h2.configr   	multidictr   utilsr   r   constr   r   r   r   r7   r   r   r   r   r   eventsr   r   r   r   r   r   r   rT   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   
exceptionsr*   r+   r,   encoding.baser-   r.   r/   encoding.protor0   r1   r2   	_registryr3   r  _typingr4   r   r   
HTTPStatusBAD_REQUESTvalueINTERNALUNAUTHORIZEDUNAUTHENTICATED	FORBIDDENPERMISSION_DENIED	NOT_FOUNDUNIMPLEMENTEDBAD_GATEWAYUNAVAILABLESERVICE_UNAVAILABLEGATEWAY_TIMEOUTTOO_MANY_REQUESTSr   r6   IntEnumr   rR   r4  r7  r;  rB  rF  r>   r>   r>   r?   <module>   st    (   w  ,#