
    AgSV                        d Z ddlZddlZddl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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!j[                  ej\                        Z/ej`                  d   d"k  rd#eejb                     fd$Z2nd#eejb                     fd%Z2d&e$d'ee	jf                     fd(Z4 G d) d*      Z5 G d+ d,e5ejl                        Z6 G d- d.e5ejn                        Z7 G d/ d0e5ejp                        Z8 G d1 d2e5ejr                        Z9 G d3 d4ejt                        Z:	 	 	 d;d5e;d6ee$   d'ee	jf                     d7eee      fd8Z<	 	 	 d;d5e;d9e	jz                  d6ee$   d'ee	jf                     d7eee      f
d:Z>y)<z6Invocation-side implementation of gRPC Asyncio Python.    N)AnyIterableListOptionalSequence)_common)_compression)_grpcio_metadata)cygrpc   )
_base_call)_base_channel)StreamStreamCall)StreamUnaryCall)UnaryStreamCall)UnaryUnaryCall)ClientInterceptor)InterceptedStreamStreamCall)InterceptedStreamUnaryCall)InterceptedUnaryStreamCall)InterceptedUnaryUnaryCall)StreamStreamClientInterceptor)StreamUnaryClientInterceptor)UnaryStreamClientInterceptor)UnaryUnaryClientInterceptor)Metadata)ChannelArgumentType)DeserializingFunction)MetadataType)RequestIterableType)RequestType)ResponseType)SerializingFunction)_timeout_to_deadlinezgrpc-python-asyncio/{}   returnc                  >    t         j                  j                         S N)asyncioTask	all_tasks     F/var/www/openai/venv/lib/python3.12/site-packages/grpc/aio/_channel.py
_all_tasksr/   7   s    ||%%''r-   c                  *    t        j                         S r(   )r)   r+   r,   r-   r.   r/   r/   <   s      ""r-   base_optionscompressionc                     t        j                  |      }t        j                  j                  t
        ff}t        |       |z   |z   S r(   )r	   create_channel_optionr   ChannelArgKeyprimary_user_agent_string_USER_AGENTtuple)r1   r2   compression_channel_argumentuser_agent_channel_arguments       r.   _augment_channel_argumentsr;   @   sX     $0#E#E$ 
   ::	
# 	l
&	'
%	&r-   c                   V   e Zd ZU dZej
                  ed<   ej                  ed<   e	ed<   e
ed<   eed<   eee      ed<   ee   ed<   ej
                  ed<   d	ej                  d
e	de
dedeee      dee   dej
                  ddfdZe	 	 ddee   deej*                     defd       Zy)_BaseMultiCallablezrBase class of all multi callable objects.

    Handles the initialization logic and stores common attributes.
    _loop_channel_method_request_serializer_response_deserializer_interceptors_referenceschannelmethodrequest_serializerresponse_deserializerinterceptors
referencesloopr&   Nc                 f    || _         || _        || _        || _        || _        || _        || _        y r(   )r>   r?   r@   rA   rB   rC   rD   )selfrE   rF   rG   rH   rI   rJ   rK   s           r.   __init__z_BaseMultiCallable.__init__c   s9     
#5 &;#)%r-   metadatar2   c                     | xs
 t               } t        | t               s%t        | t              rt        j                  |       } |rt        t	        j
                  | |       } | S )zBased on the provided values for <metadata> or <compression> initialise the final
        metadata, as it should be used for the current call.
        )r   
isinstancer8   
from_tupler	   augment_metadata)rO   r2   s     r.   _init_metadataz!_BaseMultiCallable._init_metadatau   sW     )xz(H-*Xu2M**84H..xEH r-   )NN)__name__
__module____qualname____doc__r)   AbstractEventLoop__annotations__r   
AioChannelbytesr#   r   r   r   r   r   r   rN   staticmethodr   grpcCompressionr   rT   r,   r-   r.   r=   r=   S   s   
 $$$N,,11H%6788c$$$&""& & 0	&
  5& x(9:;& I& ''& 
&$ +/26<(d../ 
 r-   r=   c                       e Zd Zdddddddedee   dee   deej                     dee	   deej                     d	ej                  eef   fd
Zy)UnaryUnaryMultiCallableNtimeoutrO   credentialswait_for_readyr2   requestrc   rO   rd   re   r2   r&   c                   | j                  ||      }| j                  sQt        |t        |      |||| j                  | j
                  | j                  | j                  | j                  
      }|S t        | j                  |||||| j                  | j
                  | j                  | j                  | j                        }|S r(   )
rT   rC   r   r$   r?   r@   rA   rB   r>   r   rM   rf   rc   rO   rd   re   r2   calls           r.   __call__z UnaryUnaryMultiCallable.__call__   s     &&x=!!!$W-((++

D6  -""((++

D r-   )rU   rV   rW   r!   r   floatr   r^   CallCredentialsboolr_   r   r   r"   rj   r,   r-   r.   ra   ra      s     $(+/6:)-26'' %	'
 <(' d223' !' d../' 
	"	";#<	='r-   ra   c                       e Zd Zdddddddedee   dee   deej                     dee	   deej                     d	ej                  eef   fd
Zy)UnaryStreamMultiCallableNrb   rf   rc   rO   rd   re   r2   r&   c                   | j                  ||      }| j                  sQt        |t        |      |||| j                  | j
                  | j                  | j                  | j                  
      }|S t        | j                  |||||| j                  | j
                  | j                  | j                  | j                        }|S r(   )
rT   rC   r   r$   r?   r@   rA   rB   r>   r   rh   s           r.   rj   z!UnaryStreamMultiCallable.__call__   s     &&x=!!"$W-((++

D6  .""((++

D r-   )rU   rV   rW   r!   r   rk   r   r^   rl   rm   r_   r   r   r"   rj   r,   r-   r.   ro   ro      s     $(+/6:)-26(( %	(
 <(( d223( !( d../( 
	#	#K$=	>(r-   ro   c                       e Zd Z	 	 	 	 	 	 d
dee   dee   dee   deej                     dee	   deej                     dej                  fd	Zy)StreamUnaryMultiCallableNrequest_iteratorrc   rO   rd   re   r2   r&   c                    | j                  ||      }| j                  sQt        |t        |      |||| j                  | j
                  | j                  | j                  | j                  
      }|S t        | j                  |||||| j                  | j
                  | j                  | j                  | j                        }|S r(   )
rT   rC   r   r$   r?   r@   rA   rB   r>   r   rM   rs   rc   rO   rd   re   r2   ri   s           r.   rj   z!StreamUnaryMultiCallable.__call__   s     &&x=!!" $W-((++

D6  ."" ((++

D r-   NNNNNN)rU   rV   rW   r   r    rk   r   r^   rl   rm   r_   r   r   rj   r,   r-   r.   rr   rr      s    
 ;?#'+/6:)-26'"#67' %' <(	'
 d223' !' d../' 
	#	#'r-   rr   c                       e Zd Z	 	 	 	 	 	 d
dee   dee   dee   deej                     dee	   deej                     dej                  fd	Zy)StreamStreamMultiCallableNrs   rc   rO   rd   re   r2   r&   c                    | j                  ||      }| j                  sQt        |t        |      |||| j                  | j
                  | j                  | j                  | j                  
      }|S t        | j                  |||||| j                  | j
                  | j                  | j                  | j                        }|S r(   )
rT   rC   r   r$   r?   r@   rA   rB   r>   r   ru   s           r.   rj   z"StreamStreamMultiCallable.__call__  s     &&x=!!# $W-((++

D6  /"" ((++

D r-   rv   )rU   rV   rW   r   r    rk   r   r^   rl   rm   r_   r   r   rj   r,   r-   r.   rx   rx     s    
 ;?#'+/6:)-26'"#67' %' <(	'
 d223' !' d../' 
	$	$'r-   rx   c                   N   e Zd ZU ej                  ed<   ej                  ed<   ee	   ed<   ee
   ed<   ee   ed<   ee   ed<   deded	eej"                     d
eej$                     deee      f
dZd Zd Zd Zd#dee   fdZd Z	 d$dedej:                  fdZdej:                  ddfdZd%dZ dede!fdZ"	 	 	 d&dedee#   dee$   dee   de%f
dZ&	 	 	 d&dedee#   dee$   dee   de'f
d Z(	 	 	 d&dedee#   dee$   dee   de)f
d!Z*	 	 	 d&dedee#   dee$   dee   de+f
d"Z,y)'Channelr>   r?   _unary_unary_interceptors_unary_stream_interceptors_stream_unary_interceptors_stream_stream_interceptorstargetoptionsrd   r2   rI   c                    g | _         g | _        g | _        g | _        |Q|D ]K  }t	        |t
              r| j                   j                  |       0t	        |t              r| j                  j                  |       \t	        |t              r| j                  j                  |       t	        |t              r| j                  j                  |       t        dj                  |      dj                  t
        j                        z   dj                  t        j                        z   dj                  t        j                        z   dj                  t        j                        z          t        j                         | _        t        j                   t#        j$                  |      t'        ||      || j                        | _        y)a  Constructor.

        Args:
          target: The target to which to connect.
          options: Configuration options for the channel.
          credentials: A cygrpc.ChannelCredentials or None.
          compression: An optional value indicating the compression method to be
            used over the lifetime of the channel.
          interceptors: An optional list of interceptors that would be used for
            intercepting any RPC executed with that channel.
        NzInterceptor {} must be z{} or z{}. )r|   r}   r~   r   rQ   r   appendr   r   r   
ValueErrorformatrU   r   get_working_loopr>   r[   r   encoder;   r?   )rM   r   r   rd   r2   rI   interceptors          r.   rN   zChannel.__init__D  sw   & *,&*,'*,'+-(#+k+FG2299+F-IJ33::;G-IJ33::;G-JK44;;KH$188E"//*E*N*NOP"//*F*O*OPQ #//*F*O*OPQ !--(E(N(NO	P   ,$ ,,.
))NN6"&w<JJ	
r-   c                    K   | S wr(   r,   rM   s    r.   
__aenter__zChannel.__aenter__w  s     s   c                 B   K   | j                  d        d {    y 7 wr(   _close)rM   exc_typeexc_valexc_tbs       r.   	__aexit__zChannel.__aexit__z  s     kk$   c                 Z  K   | j                   j                         ry | j                   j                          t               }g }g }|D ]  }	 |j	                  d      }|s|d   }|j                  j                  d      }	|	<t        |	t        j                        sWt        |	d      r|	j                   | j                   urH|t        |	d      r#|	j                  j                   | j                   urt        j                  d|	       |j!                  |	       |j!                  |        |r!|rt#        j$                  ||	       d {    |D ]  }
|
j'                           | j                   j)                          y # t
        $ r}dt        |      v rY d }~X d }~ww xY w7 [w)
Nr   )limitframer   rM   r?   _cython_callzUnrecognized call object: )rc   )r?   closedclosingr/   	get_stackAttributeErrorstrf_localsgetrQ   r   Callhasattrr   r   InternalErrorr   r)   waitcancelclose)rM   gracetaskscalls
call_taskstaskstackattribute_errorr   	candidateri   s              r.   r   zChannel._close}  s    ==! 	 
DQ/,  !HE**62I $i9y*5$--T]]B$ N;$11::$--O$ %228D  LL+%%d+e l Z,,z5999 DKKM  	w "  c/22%h :sO   A	F+F%F+F+B.F+F)6F+	F&F!F+ F!!F&&F+Nr   c                 B   K   | j                  |       d {    y 7 wr(   r   )rM   r   s     r.   r   zChannel.close  s     kk%   r   c                     t        | d      r6| j                  j                         s| j                  j                          y y y )Nr?   )r   r?   r   r   r   s    r.   __del__zChannel.__del__  s6    4$=='')##% * %r-   try_to_connectr&   c                 ^    | j                   j                  |      }t        j                  |   S r(   )r?   check_connectivity_stater   1CYGRPC_CONNECTIVITY_STATE_TO_CHANNEL_CONNECTIVITY)rM   r   results      r.   	get_statezChannel.get_state  s)     77GHHPPr-   last_observed_statec                 v   K   | j                   j                  |j                  d   d        d {   sJ y 7 w)Nr   )r?   watch_connectivity_statevalue)rM   r   s     r.   wait_for_state_changezChannel.wait_for_state_change  s>      ]];;%%a($
 
 
 	
 
s   -979c                   K   | j                  d      }|t        j                  j                  k7  rJ| j	                  |       d {    | j                  d      }|t        j                  j                  k7  rIy y 7 6w)NT)r   )r   r^   ChannelConnectivityREADYr   )rM   states     r.   channel_readyzChannel.channel_ready  sg     d3t//555,,U333NN$N7E t//5553s   AA?A=3A?;A?rF   c                      y r(   r,   )rM   rF   s     r.   _get_registered_call_handlez#Channel._get_registered_call_handle  s    r-   rG   rH   _registered_methodc           	          t        | j                  t        j                  |      ||| j                  | g| j
                        S r(   )ra   r?   r   r   r|   r>   rM   rF   rG   rH   r   s        r.   unary_unaryzChannel.unary_unary  s?     'MMNN6"!**FJJ
 	
r-   c           	          t        | j                  t        j                  |      ||| j                  | g| j
                        S r(   )ro   r?   r   r   r}   r>   r   s        r.   unary_streamzChannel.unary_stream   ?     (MMNN6"!++FJJ
 	
r-   c           	          t        | j                  t        j                  |      ||| j                  | g| j
                        S r(   )rr   r?   r   r   r~   r>   r   s        r.   stream_unaryzChannel.stream_unary  r   r-   c           	          t        | j                  t        j                  |      ||| j                  | g| j
                        S r(   )rx   r?   r   r   r   r>   r   s        r.   stream_streamzChannel.stream_stream(  s?     )MMNN6"!,,FJJ
 	
r-   r(   )F)r&   N)NNF)-rU   rV   rW   r)   rY   rZ   r   r[   r   r   r   r   r   r   r   r   r^   ChannelCredentialsr_   r   r   rN   r   r   r   rk   r   r   rm   r   r   r   r   intr   r#   r   ra   r   ro   r   rr   r   rx   r   r,   r-   r.   r{   r{   <  sc   $$$#$?@@ $%A BB $%A BB!%&C!DD1
1
 %1
 d556	1

 d../1
 x(9:;1
f IV!% !& &+Q"Q		!	!Q
!55
 

8# #  =AAE-2

 %%89
  ((=>	

 %TN
 
!
. =AAE-2

 %%89
  ((=>	

 %TN
 
"
. =AAE-2

 %%89
  ((=>	

 %TN
 
"
. =AAE-2

 %%89
  ((=>	

 %TN
 
#
r-   r{   r   r   rI   c                 (    t        | |dn|d||      S )a  Creates an insecure asynchronous Channel to a server.

    Args:
      target: The server address
      options: An optional list of key-value pairs (:term:`channel_arguments`
        in gRPC Core runtime) to configure the channel.
      compression: An optional value indicating the compression method to be
        used over the lifetime of the channel.
      interceptors: An optional sequence of interceptors that will be executed for
        any call executed with this channel.

    Returns:
      A Channel.
    Nr,   )r{   )r   r   r2   rI   s       r.   insecure_channelr   :  s&    ( o7 r-   rd   c                 <    t        | |dn||j                  ||      S )a<  Creates a secure asynchronous Channel to a server.

    Args:
      target: The server address.
      credentials: A ChannelCredentials instance.
      options: An optional list of key-value pairs (:term:`channel_arguments`
        in gRPC Core runtime) to configure the channel.
      compression: An optional value indicating the compression method to be
        used over the lifetime of the channel.
      interceptors: An optional sequence of interceptors that will be executed for
        any call executed with this channel.

    Returns:
      An aio.Channel.
    r,   )r{   _credentials)r   rd   r   r2   rI   s        r.   secure_channelr   W  s,    , o7   r-   )NNN)?rX   r)   systypingr   r   r   r   r   r^   r   r	   r
   grpc._cythonr    r   r   _callr   r   r   r   _interceptorr   r   r   r   r   r   r   r   r   	_metadatar   _typingr   r   r   r    r!   r"   r#   _utilsr$   r   __version__r7   version_infor*   r/   r_   r;   r=   ra   ro   rr   rx   r{   r   r   r   r   r,   r-   r.   <module>r      s
   =  
 : :    !    # " " ! + 5 4 4 3 7 6 6 5  ( * ! (   ! ( (&--.>.J.JKA(. (
#. #%4<T=M=M4N&1 1h*==*Z+>>+\*>>*Z*??*Z{
m## {
@ .2.2:>	)* $**+ 8$567	@ .2.2:>(( )* $**+	
 8$567r-   