a
    v=icH                     @   s  d Z ddlmZ ddlmZ ddlZddlZddlZddlmZm	Z	m
Z
mZmZmZmZ ddlZddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm Z  ddlm!Z! ddlm"Z" ddlm#Z# ddlm$Z$ ddlm%Z% ddlm&Z& ddl'm(Z( dZ)G dd dedZ*G dd de+dd ej,Z,G d!d" d"edZ-G d#d$ d$e-edZ.G d%d& d&e-edZ/G d'd( d(e-edZ0G d)d* d*e-edZ1G d+d, d,Z2G d-d. d.Z3G d/d0 d0Z4G d1d2 d2Z5G d3d4 d4e3e2ejZ6G d5d6 d6e4e2ejZ7G d7d8 d8e3e5e2ejZ8G d9d: d:e4e5e2ejZ9G d;d< d<ejZ:G d=d> d>Z;G d?d@ d@e;ejZ<G dAdB dBe;ejZ=dS )Cz3Interceptors implementation of gRPC Asyncio Python.    )ABCMeta)abstractmethodN)AsyncIterable	AwaitableCallableIteratorOptionalSequenceUnion)cygrpc   )
_base_call)AioRpcError)StreamStreamCall)StreamUnaryCall)UnaryStreamCall)UnaryUnaryCall)_API_STYLE_ERROR)_RPC_ALREADY_FINISHED_DETAILS)_RPC_HALF_CLOSED_DETAILS)Metadata)DeserializingFunction)DoneCallbackType)RequestIterableType)RequestType)ResponseIterableType)ResponseType)SerializingFunction)_timeout_to_deadlinez!Locally cancelled by application!c                   @   s<   e Zd ZdZeeejgeej	 f ejej	dddZ
dS )ServerInterceptorz^Affords intercepting incoming RPCs on the service-side.

    This is an EXPERIMENTAL API.
    )continuationhandler_call_detailsreturnc                    s   dS )a  Intercepts incoming RPCs before handing them over to a handler.

        Args:
            continuation: A function that takes a HandlerCallDetails and
                proceeds to invoke the next interceptor in the chain, if any,
                or the RPC handler lookup logic, with the call details passed
                as an argument, and returns an RpcMethodHandler instance if
                the RPC is considered serviced, or None otherwise.
            handler_call_details: A HandlerCallDetails describing the RPC.

        Returns:
            An RpcMethodHandler with which the RPC may be serviced if the
            interceptor chooses to service this RPC, or None otherwise.
        N )selfr    r!   r#   r#   f/home/droni/.local/share/virtualenvs/DPS-5Je3_V2c/lib/python3.9/site-packages/grpc/aio/_interceptor.pyintercept_service6   s    z#ServerInterceptor.intercept_serviceN)__name__
__module____qualname____doc__r   r   grpcZHandlerCallDetailsr   ZRpcMethodHandlerr&   r#   r#   r#   r%   r   0   s   r   )	metaclassc                   @   sL   e Zd ZU dZeed< ee ed< ee ed< ee	j
 ed< ee ed< dS )ClientCallDetailsa  Describes an RPC to be invoked.

    This is an EXPERIMENTAL API.

    Args:
        method: The method name of the RPC.
        timeout: An optional duration of time in seconds to allow for the RPC.
        metadata: Optional metadata to be transmitted to the service-side of
          the RPC.
        credentials: An optional CallCredentials for the RPC.
        wait_for_ready: This is an EXPERIMENTAL argument. An optional
            flag to enable :term:`wait_for_ready` mechanism.
    methodtimeoutmetadatacredentialswait_for_readyN)r'   r(   r)   r*   str__annotations__r   floatr   r+   CallCredentialsboolr#   r#   r#   r%   r-   L   s   
r-   )r.   r/   r0   r1   r2   c                   @   s   e Zd ZdZdS )ClientInterceptorz6Base class used for all Aio Client Interceptor classesN)r'   r(   r)   r*   r#   r#   r#   r%   r8   f   s   r8   c                   @   s<   e Zd ZdZeeeegef eee	ee
f dddZdS )UnaryUnaryClientInterceptorz-Affords intercepting unary-unary invocations.r    client_call_detailsrequestr"   c                    s   dS )a  Intercepts a unary-unary invocation asynchronously.

        Args:
          continuation: A coroutine that proceeds with the invocation by
            executing the next interceptor in the chain or invoking the
            actual RPC on the underlying Channel. It is the interceptor's
            responsibility to call it if it decides to move the RPC forward.
            The interceptor can use
            `call = await continuation(client_call_details, request)`
            to continue with the RPC. `continuation` returns the call to the
            RPC.
          client_call_details: A ClientCallDetails object describing the
            outgoing RPC.
          request: The request value for the RPC.

        Returns:
          An object with the RPC response.

        Raises:
          AioRpcError: Indicating that the RPC terminated with non-OK status.
          asyncio.CancelledError: Indicating that the RPC was canceled.
        Nr#   r$   r    r;   r<   r#   r#   r%   intercept_unary_unarym   s    z1UnaryUnaryClientInterceptor.intercept_unary_unaryN)r'   r(   r)   r*   r   r   r-   r   r   r
   r   r>   r#   r#   r#   r%   r9   j   s   r9   c                   @   s<   e Zd ZdZeeeegef eee	e
ef dddZdS )UnaryStreamClientInterceptorz.Affords intercepting unary-stream invocations.r:   c                    s   dS )a  Intercepts a unary-stream invocation asynchronously.

        The function could return the call object or an asynchronous
        iterator, in case of being an asyncrhonous iterator this will
        become the source of the reads done by the caller.

        Args:
          continuation: A coroutine that proceeds with the invocation by
            executing the next interceptor in the chain or invoking the
            actual RPC on the underlying Channel. It is the interceptor's
            responsibility to call it if it decides to move the RPC forward.
            The interceptor can use
            `call = await continuation(client_call_details, request)`
            to continue with the RPC. `continuation` returns the call to the
            RPC.
          client_call_details: A ClientCallDetails object describing the
            outgoing RPC.
          request: The request value for the RPC.

        Returns:
          The RPC Call or an asynchronous iterator.

        Raises:
          AioRpcError: Indicating that the RPC terminated with non-OK status.
          asyncio.CancelledError: Indicating that the RPC was canceled.
        Nr#   r=   r#   r#   r%   intercept_unary_stream   s    z3UnaryStreamClientInterceptor.intercept_unary_streamN)r'   r(   r)   r*   r   r   r-   r   r   r
   r   r@   r#   r#   r#   r%   r?      s   
r?   c                   @   s4   e Zd ZdZeeeegef ee	edddZ
dS )StreamUnaryClientInterceptorz.Affords intercepting stream-unary invocations.r    r;   request_iteratorr"   c                    s   dS )a  Intercepts a stream-unary invocation asynchronously.

        Within the interceptor the usage of the call methods like `write` or
        even awaiting the call should be done carefully, since the caller
        could be expecting an untouched call, for example for start writing
        messages to it.

        Args:
          continuation: A coroutine that proceeds with the invocation by
            executing the next interceptor in the chain or invoking the
            actual RPC on the underlying Channel. It is the interceptor's
            responsibility to call it if it decides to move the RPC forward.
            The interceptor can use
            `call = await continuation(client_call_details, request_iterator)`
            to continue with the RPC. `continuation` returns the call to the
            RPC.
          client_call_details: A ClientCallDetails object describing the
            outgoing RPC.
          request_iterator: The request iterator that will produce requests
            for the RPC.

        Returns:
          The RPC Call.

        Raises:
          AioRpcError: Indicating that the RPC terminated with non-OK status.
          asyncio.CancelledError: Indicating that the RPC was canceled.
        Nr#   r$   r    r;   rC   r#   r#   r%   intercept_stream_unary   s    z3StreamUnaryClientInterceptor.intercept_stream_unaryN)r'   r(   r)   r*   r   r   r-   r   r   r   rE   r#   r#   r#   r%   rA      s   rA   c                   @   s<   e Zd ZdZeeeegef ee	e
eef dddZdS )StreamStreamClientInterceptorz/Affords intercepting stream-stream invocations.rB   c                    s   dS )a  Intercepts a stream-stream invocation asynchronously.

        Within the interceptor the usage of the call methods like `write` or
        even awaiting the call should be done carefully, since the caller
        could be expecting an untouched call, for example for start writing
        messages to it.

        The function could return the call object or an asynchronous
        iterator, in case of being an asyncrhonous iterator this will
        become the source of the reads done by the caller.

        Args:
          continuation: A coroutine that proceeds with the invocation by
            executing the next interceptor in the chain or invoking the
            actual RPC on the underlying Channel. It is the interceptor's
            responsibility to call it if it decides to move the RPC forward.
            The interceptor can use
            `call = await continuation(client_call_details, request_iterator)`
            to continue with the RPC. `continuation` returns the call to the
            RPC.
          client_call_details: A ClientCallDetails object describing the
            outgoing RPC.
          request_iterator: The request iterator that will produce requests
            for the RPC.

        Returns:
          The RPC Call or an asynchronous iterator.

        Raises:
          AioRpcError: Indicating that the RPC terminated with non-OK status.
          asyncio.CancelledError: Indicating that the RPC was canceled.
        Nr#   rD   r#   r#   r%   intercept_stream_stream   s    z5StreamStreamClientInterceptor.intercept_stream_streamN)r'   r(   r)   r*   r   r   r-   r   r   r   r
   r   rG   r#   r#   r#   r%   rF      s   
rF   c                   @   s  e Zd ZU dZejed< ee ed< ejddddZ	dd	 Z
ejddd
dZeejddddZedddZedddZedddZeddddZee dddZee dddZee dddZejddd Zedd!d"Zee dd#d$Zddd%d&Z dS )'InterceptedCallaE  Base implementation for all intercepted call arities.

    Interceptors might have some work to do before the RPC invocation with
    the capacity of changing the invocation parameters, and some work to do
    after the RPC invocation with the capacity for accessing to the wrapped
    `UnaryUnaryCall`.

    It handles also early and later cancellations, when the RPC has not even
    started and the execution is still held by the interceptors or when the
    RPC has finished but again the execution is still held by the interceptors.

    Once the RPC is finally executed, all methods are finally done against the
    intercepted call, being at the same time the same call returned to the
    interceptors.

    As a base class for all of the interceptors implements the logic around
    final status, metadata and cancellation.
    _interceptors_task_pending_add_done_callbacksN)interceptors_taskr"   c                 C   s   || _ g | _| j | j d S N)rI   rJ   add_done_callback#_fire_or_add_pending_done_callbacks)r$   rK   r#   r#   r%   __init__  s
    zInterceptedCall.__init__c                 C   s   |    d S rL   )cancelr$   r#   r#   r%   __del__#  s    zInterceptedCall.__del__c              	   C   s   | j s
d S d}z| }| r$d}W n ttjfyB   d}Y n0 |r^| j D ]}||  qNn$| j D ]}t| j|}|	| qdg | _ d S NFT)
rJ   resultdoner   asyncioCancelledError	functoolspartial_wrap_add_done_callbackrM   )r$   rK   Zcall_completedcallcallbackr#   r#   r%   rN   &  s$    


z3InterceptedCall._fire_or_add_pending_done_callbacks)r\   unused_callr"   c                 C   s   ||  d S rL   r#   )r$   r\   r]   r#   r#   r%   rZ   @  s    z'InterceptedCall._wrap_add_done_callbackr"   c                 C   sT   | j  s| j  S z| j  }W n( ty6   Y dS  tjyJ   Y dS 0 | S NF)rI   rU   rP   rT   r   rV   rW   r$   r[   r#   r#   r%   rP   D  s    

zInterceptedCall.cancelc              
   C   sn   | j  sdS z| j  }W nH tyP } z| tjjkW  Y d }~S d }~0  tj	yd   Y dS 0 |
 S rS   )rI   rU   rT   r   coder+   
StatusCode	CANCELLEDrV   rW   	cancelledr$   r[   errr#   r#   r%   rd   T  s    
$zInterceptedCall.cancelledc              	   C   s@   | j  sdS z| j  }W n ttjfy6   Y dS 0 | S rS   )rI   rU   rT   r   rV   rW   r`   r#   r#   r%   rU   a  s    
zInterceptedCall.done)r\   r"   c              	   C   sz   | j  s| j| d S z| j  }W n" ttjfyJ   ||  Y d S 0 | r^||  nt	| j
|}|| d S rL   )rI   rU   rJ   appendrT   r   rV   rW   rX   rY   rZ   rM   )r$   r\   r[   r#   r#   r%   rM   l  s    

z!InterceptedCall.add_done_callbackc                 C   s
   t  d S rL   NotImplementedErrorrQ   r#   r#   r%   time_remaining}  s    zInterceptedCall.time_remainingc              
      s`   z| j I d H }W n@ ty< } z| W  Y d }~S d }~0  tjyP   Y d S 0 | I d H S rL   )rI   r   initial_metadatarV   rW   re   r#   r#   r%   rk     s    z InterceptedCall.initial_metadatac              
      s`   z| j I d H }W n@ ty< } z| W  Y d }~S d }~0  tjyP   Y d S 0 | I d H S rL   )rI   r   trailing_metadatarV   rW   re   r#   r#   r%   rl     s    z!InterceptedCall.trailing_metadatac              
      sf   z| j I d H }W nF ty< } z| W  Y d }~S d }~0  tjyV   tjj Y S 0 | I d H S rL   )rI   r   ra   rV   rW   r+   rb   rc   re   r#   r#   r%   ra     s    zInterceptedCall.codec              
      sb   z| j I d H }W nB ty< } z| W  Y d }~S d }~0  tjyR   t Y S 0 | I d H S rL   )rI   r   detailsrV   rW   _LOCAL_CANCELLATION_DETAILSre   r#   r#   r%   rm     s    
zInterceptedCall.detailsc              
      s`   z| j I d H }W n@ ty< } z| W  Y d }~S d }~0  tjyP   Y dS 0 | I d H S N )rI   r   debug_error_stringrV   rW   re   r#   r#   r%   rq     s    z"InterceptedCall.debug_error_stringc                    s   | j I d H }| I d H S rL   )rI   wait_for_connectionr`   r#   r#   r%   rr     s    z#InterceptedCall.wait_for_connection)!r'   r(   r)   r*   rV   Taskr4   r	   r   rO   rR   rN   r   CallrZ   r7   rP   rd   rU   rM   r   r5   rj   r   rk   rl   r+   rb   ra   r3   rm   rq   rr   r#   r#   r#   r%   rH     s*   






rH   c                   @   s   e Zd Zdd ZdS )_InterceptedUnaryResponseMixinc                 c   s"   | j  E d H }| E d H }|S rL   )rI   	__await__r$   r[   responser#   r#   r%   rv     s    z(_InterceptedUnaryResponseMixin.__await__N)r'   r(   r)   rv   r#   r#   r#   r%   ru     s   ru   c                   @   sZ   e Zd ZU eee  ed< ddddZedddZee ddd	Z	edd
dZ
dS )_InterceptedStreamResponseMixin_response_aiterNr^   c                 C   s
   d | _ d S rL   )rz   rQ   r#   r#   r%   _init_stream_response_mixin  s    z;_InterceptedStreamResponseMixin._init_stream_response_mixinc                 C  s*   | j I d H }|2 z3 d H W }|V  q6 d S rL   )rI   rw   r#   r#   r%   ,_wait_for_interceptor_task_response_iterator  s    zL_InterceptedStreamResponseMixin._wait_for_interceptor_task_response_iteratorc                 C   s   | j d u r|  | _ | j S rL   )rz   r|   rQ   r#   r#   r%   	__aiter__  s    

z)_InterceptedStreamResponseMixin.__aiter__c                    s&   | j d u r|  | _ | j d I d H S rL   )rz   r|   asendrQ   r#   r#   r%   read  s    

z$_InterceptedStreamResponseMixin.read)r'   r(   r)   r   r   r   r4   r{   r|   r}   r   r#   r#   r#   r%   ry     s   
ry   c                   @   s   e Zd ZU eee  ed< eej ed< eej	 ed< e
 Zee edddZdd Zeed	d
dZeddddZddddZdS )_InterceptedStreamRequestMixin_write_to_iterator_async_gen_write_to_iterator_queue_status_code_task)rC   r"   c                 C   s8   |d u r.t jdd| _|  | _d | _| j}nd | _|S )Nr   )maxsize)rV   Queuer   !_proxy_writes_as_request_iteratorr   r   )r$   rC   r#   r#   r%   _init_stream_request_mixin  s    
z9_InterceptedStreamRequestMixin._init_stream_request_mixinc                 C  s4   | j I d H  | j I d H }|tju r(q0|V  qd S rL   )rI   r   getr   _FINISH_ITERATOR_SENTINEL)r$   valuer#   r#   r%   r     s
    
z@_InterceptedStreamRequestMixin._proxy_writes_as_request_iterator)r<   r[   c                    sL   | j d u r| j| | _ tj| j| j|| j ftjdI d H  d S )N)return_when)	r   _loopcreate_taskra   rV   waitr   putFIRST_COMPLETEDr$   r<   r[   r#   r#   r%   &_write_to_iterator_queue_interruptible  s    
zE_InterceptedStreamRequestMixin._write_to_iterator_queue_interruptibleNr<   r"   c              	      s   | j d u rttz| jI d H }W n" tjtfyF   tt	Y n0 |
 r\tt	n|jrltt| ||I d H  |
 rtt	d S rL   )r   r   
UsageErrorr   rI   rV   rW   r   InvalidStateErrorr   rU   _done_writing_flagr   r   r   r#   r#   r%   write	  s    


z$_InterceptedStreamRequestMixin.writer^   c                    s\   | j du rttz| jI dH }W n tjyB   ttY n0 | 	t
j|I dH  dS )zUSignal peer that client is done writing.

        This method is idempotent.
        N)r   r   r   r   rI   rV   rW   r   r   r   r   r   r`   r#   r#   r%   done_writing  s    

z+_InterceptedStreamRequestMixin.done_writing)r'   r(   r)   r   r   r   r4   rV   r   rs   objectr   r   r   r   rH   r   r   r   r#   r#   r#   r%   r     s   
	r   c                       s   e Zd ZU dZejed< ejed< e	e
 eee eeej ee ejeeeejdd fddZe	e
 eee ee eej ee eeeed
d	d
Zee dddZ  ZS )InterceptedUnaryUnaryCallzUsed for running a `UnaryUnaryCall` wrapped by interceptors.

    For the `__await__` method is it is proxied to the intercepted call only when
    the interceptor task is finished.
    r   _channelNinterceptorsr<   r/   r0   r1   r2   channelr.   request_serializerresponse_deserializerloopr"   c                    s<   || _ || _|| ||||||||	|
	}t | d S rL   )r   r   r   _invokesuperrO   r$   r   r<   r/   r0   r1   r2   r   r.   r   r   r   rK   	__class__r#   r%   rO   ?  s    z"InterceptedUnaryUnaryCall.__init__
r   r.   r/   r0   r1   r2   r<   r   r   r"   c
                    sJ   t t tttjd fdd t|||||}
 t||
|I dH S )(Run the RPC call wrapped in interceptorsr   r;   r<   r"   c                    sx   t | d }|rHt | }||||I d H }t|tjr>|S t|S n,t|t|j	|j
|j|jj|jj
S d S rL   )nextrX   rY   r>   
isinstancer   r   UnaryUnaryCallResponser   r/   r0   r1   r2   r   r.   r   )r   r;   r<   interceptorr    Zcall_or_response_run_interceptorr   r   r$   r#   r%   r   Z  s"    



z;InterceptedUnaryUnaryCall._invoke.<locals>._run_interceptorN)r   r9   r-   r   r   r   iterr$   r   r.   r/   r0   r1   r2   r<   r   r   r;   r#   r   r%   r   P  s    
z!InterceptedUnaryUnaryCall._invoker^   c                 C   s
   t  d S rL   rh   rQ   r#   r#   r%   rj   z  s    z(InterceptedUnaryUnaryCall.time_remaining)r'   r(   r)   r*   rV   AbstractEventLoopr4   r   
AioChannelr	   r9   r   r   r5   r   r+   r6   r7   bytesr   r   rO   r   r   rj   __classcell__r#   r#   r   r%   r   3  s*   



*r   c                       s   e Zd ZU dZejed< ejed< e	e
j Zee ee	e ee	ej e	e ejeeeejdd fddZee ee	e e	e e	ej e	e eeeed
d	d
Ze	e dddZ  ZS )InterceptedUnaryStreamCallz=Used for running a `UnaryStreamCall` wrapped by interceptors.r   r   Nr   c                    sJ   || _ || _|   d | _|| ||||||||	|
	}t | d S rL   )r   r   r{   %_last_returned_call_from_interceptorsr   r   r   rO   r   r   r#   r%   rO     s    z#InterceptedUnaryStreamCall.__init__r   c
                    sJ   t t tttjd fdd t|||||}
 t||
|I dH S )r   r   c                    s   t | d }|rVt | }||||I d H }t|tjrB|_ntj|_jS t|t	|j
|j|j|jj|jj
_jS d S rL   )r   rX   rY   r@   r   r   r   r   UnaryStreamCallResponseIteratorr   r/   r0   r1   r2   r   r.   r   )r   r;   r<   r   r    call_or_response_iteratorr   r#   r%   r     s0    


z<InterceptedUnaryStreamCall._invoke.<locals>._run_interceptorN)r   r?   r-   r   r   r   r   r   r#   r   r%   r     s    !
z"InterceptedUnaryStreamCall._invoker^   c                 C   s
   t  d S rL   rh   rQ   r#   r#   r%   rj     s    z)InterceptedUnaryStreamCall.time_remaining)r'   r(   r)   r*   rV   r   r4   r   r   r   r   r   r   r	   r?   r   r5   r   r+   r6   r7   r   r   r   rO   r9   r   rj   r   r#   r#   r   r%   r   ~  s,   




0r   c                       s   e Zd ZU dZejed< ejed< e	e
 ee ee eeej ee ejeeeejdd fddZe	e
 eee ee eej ee eeeed
d	d
Zee dddZ  ZS )InterceptedStreamUnaryCallzUsed for running a `StreamUnaryCall` wrapped by interceptors.

    For the `__await__` method is it is proxied to the intercepted call only when
    the interceptor task is finished.
    r   r   Nr   rC   r/   r0   r1   r2   r   r.   r   r   r   r"   c                    sF   || _ || _| |}|| ||||||||	|
	}t | d S rL   )r   r   r   r   r   r   rO   r$   r   rC   r/   r0   r1   r2   r   r.   r   r   r   rK   r   r#   r%   rO     s    
z#InterceptedStreamUnaryCall.__init__
r   r.   r/   r0   r1   r2   rC   r   r   r"   c
                    sJ   t t tttjd fdd t|||||}
 t||
|I dH S )r   r   r;   rC   r"   c                    s^   t | d }|r.t | }||||I d H S t|t|j|j|j|j	j
|jj
S d S rL   )r   rX   rY   rE   r   r   r/   r0   r1   r2   r   r.   r   )r   r;   rC   r   r    r   r#   r%   r     s    

z<InterceptedStreamUnaryCall._invoke.<locals>._run_interceptorN)r   r9   r-   r   r   r   r   r$   r   r.   r/   r0   r1   r2   rC   r   r   r;   r#   r   r%   r     s    
z"InterceptedStreamUnaryCall._invoker^   c                 C   s
   t  d S rL   rh   rQ   r#   r#   r%   rj     s    z)InterceptedStreamUnaryCall.time_remaining)r'   r(   r)   r*   rV   r   r4   r   r   r	   rA   r   r   r5   r   r+   r6   r7   r   r   r   rO   r   r   rj   r   r#   r#   r   r%   r     s,   



'r   c                       s   e Zd ZU dZejed< ejed< e	e
j Zee e	e e	e ee	ej e	e ejeeeejdd fddZee ee	e e	e e	ej e	e eeeed
d	d
Ze	e dddZ  ZS )InterceptedStreamStreamCallz>Used for running a `StreamStreamCall` wrapped by interceptors.r   r   Nr   c                    sT   || _ || _|   | |}d | _|| ||||||||	|
	}t | d S rL   )	r   r   r{   r   r   r   r   r   rO   r   r   r#   r%   rO   "  s    
z$InterceptedStreamStreamCall.__init__r   c
                    sJ   t t tttjd fdd t|||||}
 t||
|I dH S )r   r   c                    s   t | d }|rVt | }||||I d H }t|tjrB|_ntj|_jS t|t	|j
|j|j|jj|jj
_jS d S rL   )r   rX   rY   rG   r   r   r   r    StreamStreamCallResponseIteratorr   r/   r0   r1   r2   r   r.   r   )r   r;   rC   r   r    r   r   r#   r%   r   A  s2    

z=InterceptedStreamStreamCall._invoke.<locals>._run_interceptorN)r   rF   r-   r   r   r   r   r   r#   r   r%   r   6  s    !
z#InterceptedStreamStreamCall._invoker^   c                 C   s
   t  d S rL   rh   rQ   r#   r#   r%   rj   g  s    z*InterceptedStreamStreamCall.time_remaining)r'   r(   r)   r*   rV   r   r4   r   r   r   r   r   r   r	   rF   r   r5   r   r+   r6   r7   r   r   r   rO   r   r   rj   r   r#   r#   r   r%   r     s.   




1r   c                   @   s   e Zd ZU dZeed< eddddZeddd	Zedd
dZ	edddZ
ddddZee dddZee dddZee dddZejdddZedddZee dddZdd ZddddZdS ) r   z4Final UnaryUnaryCall class finished with a response.	_responseN)rx   r"   c                 C   s
   || _ d S rL   r   )r$   rx   r#   r#   r%   rO   o  s    zUnaryUnaryCallResponse.__init__r^   c                 C   s   dS r_   r#   rQ   r#   r#   r%   rP   r  s    zUnaryUnaryCallResponse.cancelc                 C   s   dS r_   r#   rQ   r#   r#   r%   rd   u  s    z UnaryUnaryCallResponse.cancelledc                 C   s   dS )NTr#   rQ   r#   r#   r%   rU   x  s    zUnaryUnaryCallResponse.donec                 C   s
   t  d S rL   rh   )r$   Zunused_callbackr#   r#   r%   rM   {  s    z(UnaryUnaryCallResponse.add_done_callbackc                 C   s
   t  d S rL   rh   rQ   r#   r#   r%   rj   ~  s    z%UnaryUnaryCallResponse.time_remainingc                    s   d S rL   r#   rQ   r#   r#   r%   rk     s    z'UnaryUnaryCallResponse.initial_metadatac                    s   d S rL   r#   rQ   r#   r#   r%   rl     s    z(UnaryUnaryCallResponse.trailing_metadatac                    s   t jjS rL   )r+   rb   OKrQ   r#   r#   r%   ra     s    zUnaryUnaryCallResponse.codec                    s   dS ro   r#   rQ   r#   r#   r%   rm     s    zUnaryUnaryCallResponse.detailsc                    s   d S rL   r#   rQ   r#   r#   r%   rq     s    z)UnaryUnaryCallResponse.debug_error_stringc                 c   s   | j S rL   r   rQ   r#   r#   r%   rv     s    z UnaryUnaryCallResponse.__await__c                    s   d S rL   r#   rQ   r#   r#   r%   rr     s    z*UnaryUnaryCallResponse.wait_for_connection)r'   r(   r)   r*   r   r4   rO   r7   rP   rd   rU   rM   r   r5   rj   r   rk   rl   r+   rb   ra   r3   rm   rq   rv   rr   r#   r#   r#   r%   r   k  s   
r   c                   @   s  e Zd ZU eejejf ed< ee	 ed< eejejf ee	 ddddZ
eddd	Zedd
dZedddZddddZee dddZee dddZee dddZejdddZedddZee dddZdd ZddddZdS ) _StreamCallResponseIterator_call_response_iteratorN)r[   response_iteratorr"   c                 C   s   || _ || _d S rL   )r   r   )r$   r[   r   r#   r#   r%   rO     s    z$_StreamCallResponseIterator.__init__r^   c                 C   s
   | j  S rL   )r   rP   rQ   r#   r#   r%   rP     s    z"_StreamCallResponseIterator.cancelc                 C   s
   | j  S rL   )r   rd   rQ   r#   r#   r%   rd     s    z%_StreamCallResponseIterator.cancelledc                 C   s
   | j  S rL   )r   rU   rQ   r#   r#   r%   rU     s    z _StreamCallResponseIterator.donec                 C   s   | j | d S rL   )r   rM   )r$   r\   r#   r#   r%   rM     s    z-_StreamCallResponseIterator.add_done_callbackc                 C   s
   | j  S rL   )r   rj   rQ   r#   r#   r%   rj     s    z*_StreamCallResponseIterator.time_remainingc                    s   | j  I d H S rL   )r   rk   rQ   r#   r#   r%   rk     s    z,_StreamCallResponseIterator.initial_metadatac                    s   | j  I d H S rL   )r   rl   rQ   r#   r#   r%   rl     s    z-_StreamCallResponseIterator.trailing_metadatac                    s   | j  I d H S rL   )r   ra   rQ   r#   r#   r%   ra     s    z _StreamCallResponseIterator.codec                    s   | j  I d H S rL   )r   rm   rQ   r#   r#   r%   rm     s    z#_StreamCallResponseIterator.detailsc                    s   | j  I d H S rL   )r   rq   rQ   r#   r#   r%   rq     s    z._StreamCallResponseIterator.debug_error_stringc                 C   s
   | j  S rL   )r   r}   rQ   r#   r#   r%   r}     s    z%_StreamCallResponseIterator.__aiter__c                    s   | j  I d H S rL   )r   rr   rQ   r#   r#   r%   rr     s    z/_StreamCallResponseIterator.wait_for_connection)r'   r(   r)   r
   r   r   r   r4   r   r   rO   r7   rP   rd   rU   rM   r   r5   rj   r   rk   rl   r+   rb   ra   r3   rm   rq   r}   rr   r#   r#   r#   r%   r     s&   
r   c                   @   s   e Zd ZdZedddZdS )r   zAUnaryStreamCall class wich uses an alternative response iterator.r^   c                    s
   t  d S rL   rh   rQ   r#   r#   r%   r     s    z$UnaryStreamCallResponseIterator.readN)r'   r(   r)   r*   r   r   r#   r#   r#   r%   r     s   r   c                   @   sN   e Zd ZdZedddZeddddZddd	d
Ze	e
dddZdS )r   zBStreamStreamCall class wich uses an alternative response iterator.r^   c                    s
   t  d S rL   rh   rQ   r#   r#   r%   r     s    z%StreamStreamCallResponseIterator.readNr   c                    s
   t  d S rL   rh   )r$   r<   r#   r#   r%   r     s    z&StreamStreamCallResponseIterator.writec                    s
   t  d S rL   rh   rQ   r#   r#   r%   r     s    z-StreamStreamCallResponseIterator.done_writingc                 C   s   | j jS rL   )r   r   rQ   r#   r#   r%   r     s    z3StreamStreamCallResponseIterator._done_writing_flag)r'   r(   r)   r*   r   r   r   r   r   propertyr7   r   r#   r#   r#   r%   r     s   r   )>r*   abcr   r   rV   collectionsrX   typingr   r   r   r   r   r	   r
   r+   Zgrpc._cythonr   rp   r   r   r   r   r   r   r   r   r   r   	_metadatar   Z_typingr   r   r   r   r   r   r   _utilsr   rn   r   
namedtupler-   r8   r9   r?   rA   rF   rH   ru   ry   r   r   r   r   r   r   r   r   r   r#   r#   r#   r%   <module>   s   $
!%)- 2YKPJS00
