
    Ng                     F   d Z ddlZddlZddlZddlZddlmZmZmZm	Z	 ddl
Z
ddl
mZ ddlmZ  ej        e          ZdZ G d d ej        d	d
          e
j                  Z G d de
j                  Z G d de
j                  Zde
j        defdZdededefdZdS )z#Internal utilities for gRPC Python.    N)CallableDictOptionalSequence)_common)DoneCallbackTypez6Exception calling connectivity future "done" callback!c                       e Zd ZdS )RpcMethodHandlerN)__name__
__module____qualname__     K/var/www/html/ai-engine/env/lib/python3.11/site-packages/grpc/_utilities.pyr
   r
   !   s          	Dr   r
   _RpcMethodHandler)request_streamingresponse_streamingrequest_deserializerresponse_serializerunary_unaryunary_streamstream_unarystream_streamc                       e Zd ZU eed<   eeej        f         ed<   dedeeej        f         fdZdefdZ	dej
        deej                 fd	Zd
S )DictionaryGenericHandler_name_method_handlersservicemethod_handlersc                 `    | _         fd|                                D             | _        d S )Nc                 B    i | ]\  }}t          j        |          |S r   )r   fully_qualified_method).0methodmethod_handlerr   s      r   
<dictcomp>z5DictionaryGenericHandler.__init__.<locals>.<dictcomp><   s<     !
 !
 !
& *7F;;^!
 !
 !
r   )r   itemsr   )selfr   r   s    ` r   __init__z!DictionaryGenericHandler.__init__8   sI     
!
 !
 !
 !
*9*?*?*A*A!
 !
 !
r   returnc                     | j         S N)r   r(   s    r   service_namez%DictionaryGenericHandler.service_nameA   s
    zr   handler_call_detailsc                 D    |j         }| j                            |          S r,   )r$   r   get)r(   r/   details_methods      r   r   z DictionaryGenericHandler.serviceD   s*     .4$((
 
 	
r   N)r   r   r   str__annotations__r   grpcr
   r)   r.   HandlerCallDetailsr   r   r   r   r   r   r   4   s         JJJ3 556666

-1#t7L2L-M
 
 
 
c    
$($;
	$'	(
 
 
 
 
 
r   r   c                   \   e Zd ZU ej        ed<   ej        ed<   eed<   eed<   e	e
         ed<   dej        fdZdee         d	d
fdZdeej                 d	d
fdZd	efdZd	efdZd	efdZd	efdZddee         d	d
fdZddee         d	d
fdZddee         d	d
fdZdefdZd Zd Zd
S )_ChannelReadyFuture
_condition_channel_matured
_cancelled_done_callbackschannelc                 n    t          j                    | _        || _        d| _        d| _        g | _        d S )NF)	threading	Conditionr9   r:   r;   r<   r=   )r(   r>   s     r   r)   z_ChannelReadyFuture.__init__T   s5    #-//!r   timeoutr*   Nc                    |d nt          j                     |z   }| j        5  	 | j        rt          j                    | j        r	 d d d            d S || j                                         nJ|t          j                     z
  }|dk     rt          j                    | j                            |           # 1 swxY w Y   d S )NTr   )rB   )timer9   r<   r5   FutureCancelledErrorr;   waitFutureTimeoutError)r(   rB   until	remainings       r   _blockz_ChannelReadyFuture._block\   s-   TY[[7-B_ 	D 	DD? D3555] 
D	D 	D 	D 	D 	D 	D 	D 	D },,....$)DIKK$7	$q=="&"9";";; O000CCCD	D 	D 	D 	D 	D 	D 	D 	D 	D 	Ds   $B:A'B::B>B>connectivityc                    | j         5  | j        sn|t          j        j        u r[d| _        | j                            | j                   | j         	                                 t          | j                  }d | _        n	 d d d            d S 	 d d d            n# 1 swxY w Y   |D ]=}	  ||            # t          $ r" t                              t                     Y :w xY wd S )NT)r9   r<   r5   ChannelConnectivityREADYr;   r:   unsubscribe_update
notify_alltupler=   	Exception_LOGGER	exception$_DONE_CALLBACK_EXCEPTION_LOG_MESSAGE)r(   rK   done_callbacksdone_callbacks       r   rP   z_ChannelReadyFuture._updaten   sj   _ 	 	O
 D$<$BBB $))$,777**,,,!&t';!<!<'+$$	 	 	 	 	 	 	 	 %	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 , 	H 	HMHd#### H H H!!"FGGGGGH	H 	Hs$   A7BB B)B55)C! C!c                    | j         5  | j        s[d| _        | j                            | j                   | j                                          t          | j                  }d | _        n	 d d d            dS 	 d d d            n# 1 swxY w Y   |D ]=}	  ||            # t          $ r" t                              t                     Y :w xY wdS )NTF)r9   r;   r<   r:   rO   rP   rQ   rR   r=   rS   rT   rU   rV   )r(   rW   rX   s      r   cancelz_ChannelReadyFuture.cancel   sT   _ 	 	= "&))$,777**,,,!&t';!<!<'+$$	 	 	 	 	 	 	 	 %	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 , 	H 	HMHd#### H H H!!"FGGGGGH ts$   A$BB
B
B"")CCc                 R    | j         5  | j        cd d d            S # 1 swxY w Y   d S r,   )r9   r<   r-   s    r   	cancelledz_ChannelReadyFuture.cancelled   ss    _ 	# 	#?	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#s     c                 d    | j         5  | j         o| j         cd d d            S # 1 swxY w Y   d S r,   r9   r<   r;   r-   s    r   runningz_ChannelReadyFuture.running   s    _ 	= 	=&<t}+<	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	=s   %))c                 `    | j         5  | j        p| j        cd d d            S # 1 swxY w Y   d S r,   r^   r-   s    r   donez_ChannelReadyFuture.done   sz    _ 	4 	4?3dm	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4s   #''c                 0    |                      |           d S r,   rJ   r(   rB   s     r   resultz_ChannelReadyFuture.result       Gr   c                 0    |                      |           d S r,   rc   rd   s     r   rU   z_ChannelReadyFuture.exception   rf   r   c                 0    |                      |           d S r,   rc   rd   s     r   	tracebackz_ChannelReadyFuture.traceback   rf   r   fnc                     | j         5  | j        s/| j        s(| j                            |           	 d d d            d S d d d            n# 1 swxY w Y    ||            d S r,   )r9   r<   r;   r=   append)r(   rj   s     r   add_done_callbackz%_ChannelReadyFuture.add_done_callback   s    _ 	 	? 4= $++B///	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	
 	4s   *AAAc                     | j         5  | j                            | j        d           d d d            d S # 1 swxY w Y   d S )NT)try_to_connect)r9   r:   	subscriberP   r-   s    r   startz_ChannelReadyFuture.start   s    _ 	G 	GM##DL#FFF	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	Gs   "7;;c                     | j         5  | j        s&| j        s| j                            | j                   d d d            d S # 1 swxY w Y   d S r,   )r9   r<   r;   r:   rO   rP   r-   s    r   __del__z_ChannelReadyFuture.__del__   s    _ 	8 	8? 84= 8))$,777	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8s   .AA
Ar,   )r   r   r   r@   rA   r4   r5   Channelboolr   r   r)   r   floatrJ   rM   rP   rZ   r\   r_   ra   re   rU   ri   r   rm   rq   rs   r   r   r   r8   r8   M   s        ####lNNNh''''" " " " "Dhuo D$ D D D D$HHT-E$F H4 H H H H(    &#4 # # # #= = = = =4d 4 4 4 4 huo      % D     % D    $4    G G G8 8 8 8 8r   r8   r>   r*   c                 L    t          |           }|                                 |S r,   )r8   rq   )r>   ready_futures     r   channel_ready_futurery      s'    &w//Lr   version1version2c                    |                      d          }|                     d          }	 t          d          D ]`}t          ||                   t          ||                   k     r dS t          ||                   t          ||                   k    r dS an# t          $ r Y dS w xY wt	          |          t	          |          k     S )a  
    Compares two versions in the format '1.60.1' or '1.60.1.dev0'.

    This method will be used in all stubs generated by grpcio-tools to check whether
    the stub version is compatible with the runtime grpcio.

    Args:
        version1: The first version string.
        version2: The second version string.

    Returns:
        True if version1 is lower, False otherwise.
    .   TF)splitrangeint
ValueErrorlen)rz   r{   version1_listversion2_listis        r   first_version_is_lowerr      s     NN3''MNN3''Mq 	 	A=#$$s=+;'<'<<<tt]1%&&]1-=)>)>>>uu ?	
    uu
 }M 2 222s   >B ,-B B 
B+*B+)__doc__collectionsloggingr@   rD   typingr   r   r   r   r5   r   grpc._typingr   	getLoggerr   rT   rV   
namedtupler
   ServiceRpcHandlerr   Futurer8   rt   ry   r3   ru   r   r   r   r   <module>r      s   * )           5 5 5 5 5 5 5 5 5 5 5 5        ) ) ) ) ) )
'
H
%
% = %
	 	 	 	 	K		
  		 	 	&
 
 
 
 
t5 
 
 
2l8 l8 l8 l8 l8$+ l8 l8 l8^$, 3F    3S 3C 3D 3 3 3 3 3 3r   