
    '                         S SK J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  \R                  (       a  S SK
Jr   " S S	\R                  5      r " S
 S\R                  5      rg)    )absolute_importN)Any)Union)futures)AcknowledgeStatus)StreamingPullManagerc                   ^   ^  \ rS rSrSrSU 4S jjrSSS\4S jrS\4S	 jr	S\4S
 jr
SrU =r$ )StreamingPullFuture   a(  Represents a process that asynchronously performs streaming pull and
schedules messages to be processed.

This future is resolved when the process is stopped (via :meth:`cancel`) or
if it encounters an unrecoverable error. Calling `.result()` will cause
the calling thread to block indefinitely.
managerr   c                    > [         [        U ]  5         Xl        U R                  R	                  U R
                  5        SU l        g )NF)superr
   __init___StreamingPullFuture__manageradd_close_callback_on_close_callback_StreamingPullFuture__cancelled)selfr   	__class__s     <lib/third_party/google/cloud/pubsub_v1/subscriber/futures.pyr   StreamingPullFuture.__init__'   s6    !413 ))$*A*AB     resultc                 |    U R                  5       (       a  g Uc  U R                  S5        g U R                  U5        g )NT)done
set_resultset_exception)r   r   r   s      r   r   &StreamingPullFuture._on_close_callback-   s1    99;; >OOD!v&r   returnc                 F    SU l         U R                  R                  5         g)aI  Stops pulling messages and shutdowns the background thread consuming
messages.

The method always returns ``True``, as the shutdown is always initiated.
However, if the background stream is already being shut down or the shutdown
has completed, this method is a no-op.

.. versionchanged:: 2.4.1
   The method does not block anymore, it just triggers the shutdown and returns
   immediately. To block until the background stream is terminated, call
   :meth:`result()` after cancelling the future.

.. versionchanged:: 2.10.0
   The method always returns ``True`` instead of ``None``.
T)r   r   closer   s    r   cancelStreamingPullFuture.cancel8   s    $  r   c                     U R                   $ )z?
Returns:
    ``True`` if the subscription has been cancelled.
)r   r"   s    r   	cancelledStreamingPullFuture.cancelledN   s    
 r   )__cancelled	__manager)r   r   )__name__
__module____qualname____firstlineno____doc__r   r   r   boolr#   r&   __static_attributes____classcell__r   s   @r   r
   r
      s>    !	'*@ 	'# 	' , 4    r   r
   c                   b   ^  \ rS rSrSrS\4S jrS\4S jrS	S\\	\
4   S\4U 4S jjjrSrU =r$ )
FutureV   zThis future object is for subscribe-side calls.

Calling :meth:`result` will resolve the future by returning the message
ID, unless an error occurs.
r   c                     gzYActions in Pub/Sub generally may not be canceled.

This method always returns ``False``.
F r"   s    r   r#   Future.cancel]       
 r   c                     gr7   r8   r"   s    r   r&   Future.cancelledd   r:   r   timeoutc                    > [         TU ]  US9$ )a  Return a success code or raise an exception.

This blocks until the operation completes successfully and
returns the error code unless an exception is raised.

Args:
    timeout: The number of seconds before this call
        times out and raises TimeoutError.

Returns:
    AcknowledgeStatus.SUCCESS if the operation succeeded.

Raises:
    concurrent.futures.TimeoutError: If the request times out.
    AcknowledgeError: If the operation did not succeed for another
        reason.
)r=   )r   r   )r   r=   r   s     r   r   Future.resultk   s    $ w~g~..r   r8   )N)r*   r+   r,   r-   r.   r/   r#   r&   r   intfloatr   r   r0   r1   r2   s   @r   r4   r4   V   sB     4 /eCJ/ /;L / /r   r4   )
__future__r   typingr   r   google.cloud.pubsub_v1r   ,google.cloud.pubsub_v1.subscriber.exceptionsr   TYPE_CHECKINGBgoogle.cloud.pubsub_v1.subscriber._protocol.streaming_pull_managerr   r4   r
   r8   r   r   <module>rH      sH    '    * J	
5 '.. 5 p'/W^^ '/r   