
    (ph                     |    S r SSKrSSKrSSKJr  SSKJr  SSKJr  SSKJr  Sr	 " S S	\R                  5      rS
 rg)z'Utilities for the gRPC Python Beta API.    N)implementations)
interfaces)callable_util)futurez6Exception calling connectivity future "done" callback!c                   n    \ rS rSrS rS rS rS rS rS r	S r
SS
 jrSS jrSS jrS rS rS rSrg	)_ChannelReadyFuture   c                 n    [         R                  " 5       U l        Xl        SU l        SU l        / U l        g )NF)	threading	Condition
_condition_channel_matured
_cancelled_done_callbacks)selfchannels     F/var/www/html/venv/lib/python3.13/site-packages/grpc/beta/utilities.py__init___ChannelReadyFuture.__init__   s-    #--/!    c                    Uc  S O[         R                   " 5       U-   nU R                      U R                  (       a  [        R                  " 5       eU R
                  (       a
   S S S 5        g Uc  U R                  R                  5         OLU[         R                   " 5       -
  nUS:  a  [        R                  " 5       eU R                  R                  US9  M  ! , (       d  f       g = f)Nr   )timeout)timer   r   r   CancelledErrorr   waitTimeoutError)r   r   until	remainings       r   _block_ChannelReadyFuture._block'   s    TYY[7-B__?? //11]] _ },,.$)DIIK$7	$q="("5"5"77 OO000C  _s   :C-A,C
C'c                    U R                      U R                  (       d  U[        R                  R                  L ac  SU l        U R                  R                  U R                  5        U R                   R                  5         [        U R                  5      nS U l        O
 S S S 5        g  S S S 5        W H  n[        R                  " U[        U 5        M!     g ! , (       d  f       N4= f)NT)r   r   r   ChannelConnectivityREADYr   r   unsubscribe_update
notify_alltupler   r   call_logging_exceptions$_DONE_CALLBACK_EXCEPTION_LOG_MESSAGE)r   connectivitydone_callbacksdone_callbacks       r   r&   _ChannelReadyFuture._update9   s    __OO J$B$B$H$HH $))$,,7**,!&t';';!<'+$ _ %  ,M11CT , _s   BC
C&c                    U R                      U R                  (       dc  SU l        U R                  R	                  U R
                  5        U R                   R                  5         [        U R                  5      nS U l        O
 S S S 5        g S S S 5        W H  n[        R                  " U[        U 5        M!     g! , (       d  f       N4= f)NTF)r   r   r   r   r%   r&   r'   r(   r   r   r)   r*   )r   r,   r-   s      r   cancel_ChannelReadyFuture.cancelL   s    __=="&))$,,7**,!&t';';!<'+$ _ %  ,M11CT ,
  _s   A6B;;
C	c                 h    U R                      U R                  sS S S 5        $ ! , (       d  f       g = fN)r   r   r   s    r   	cancelled_ChannelReadyFuture.cancelled^   s    __?? __s   #
1c                     U R                      U R                  (       + =(       a    U R                  (       + sS S S 5        $ ! , (       d  f       g = fr3   r   r   r   r4   s    r   running_ChannelReadyFuture.runningb   s)    __&<t}}+< __s   )A  
Ac                     U R                      U R                  =(       d    U R                  sS S S 5        $ ! , (       d  f       g = fr3   r8   r4   s    r   done_ChannelReadyFuture.donef   s#    __??3dmm __s	   6
ANc                 &    U R                  U5        g r3   r    r   r   s     r   result_ChannelReadyFuture.resultj       Gr   c                 &    U R                  U5        g r3   r?   r@   s     r   	exception_ChannelReadyFuture.exceptionn   rC   r   c                 &    U R                  U5        g r3   r?   r@   s     r   	traceback_ChannelReadyFuture.tracebackr   rC   r   c                     U R                      U R                  (       d6  U R                  (       d%  U R                  R	                  U5         S S S 5        g S S S 5        U" U 5        g ! , (       d  f       N= fr3   )r   r   r   r   append)r   fns     r   add_done_callback%_ChannelReadyFuture.add_done_callbackv   sG    __??4==$$++B/ __
 	4 _s   ?A&&
A4c                     U R                      U R                  R                  U R                  SS9  S S S 5        g ! , (       d  f       g = f)NT)try_to_connect)r   r   	subscriber&   r4   s    r   start_ChannelReadyFuture.start~   s.    __MM##DLL#F __s	   %;
A	c                     U R                      U R                  (       d6  U R                  (       d%  U R                  R	                  U R
                  5        S S S 5        g ! , (       d  f       g = fr3   )r   r   r   r   r%   r&   r4   s    r   __del___ChannelReadyFuture.__del__   s6    __??4==))$,,7 __s   AA
A,)r   r   r   r   r   r3   )__name__
__module____qualname____firstlineno__r   r    r&   r0   r5   r9   r<   rA   rE   rH   rM   rR   rU   __static_attributes__ r   r   r   r      sE    "D$&$#=4G8r   r   c                 <    [        U 5      nUR                  5         U$ )a  Creates a future.Future tracking when an implementations.Channel is ready.

Cancelling the returned future.Future does not tell the given
implementations.Channel to abandon attempts it may have been making to
connect; cancelling merely deactivates the return future.Future's
subscription to the given implementations.Channel's connectivity.

Args:
  channel: An implementations.Channel.

Returns:
  A future.Future that matures when the given Channel has connectivity
    interfaces.ChannelConnectivity.READY.
)r   rR   )r   ready_futures     r   channel_ready_futurer_      s      'w/Lr   )__doc__r   r   	grpc.betar   r   grpc.framework.foundationr   r   r*   Futurer   r_   r\   r   r   <module>rd      s@    .   &   3 , = %
g8&-- g8Tr   