o
    ?e                     @   s>   d Z ddlmZ G dd deZdadd ZG dd	 d	ZdS )
z)Cancellation support for eager execution.    )
pywrap_tfec                   @   s:   e Zd ZdZdgZdd Zedd Zdd Zd	d
 Z	dS )CancellationManagerz0A mechanism for cancelling blocking computation._implc                 C   s   t  | _d S N)r   ZTFE_NewCancellationManagerr   self r   e/home/www/facesmatcher.com/pyenv/lib/python3.10/site-packages/tensorflow/python/eager/cancellation.py__init__   s   zCancellationManager.__init__c                 C   s   t | jS )zEReturns `True` if `CancellationManager.start_cancel` has been called.)r   Z"TFE_CancellationManagerIsCancelledr   r   r   r   r	   is_cancelled   s   z CancellationManager.is_cancelledc                 C   s   t | j dS )zGCancels blocking operations that have been registered with this object.N)r   Z"TFE_CancellationManagerStartCancelr   r   r   r   r	   start_cancel!   s   z CancellationManager.start_cancelc                    s    fdd}|S )Nc                     s:   t   | i |W  d    S 1 sw   Y  d S r   )CancellationManagerContext)argskwargsconcrete_functionr   r   r	   cancellable&   s   
$z@CancellationManager.get_cancelable_function.<locals>.cancellabler   )r   r   r   r   r   r	   get_cancelable_function%   s   z+CancellationManager.get_cancelable_functionN)
__name__
__module____qualname____doc__	__slots__r
   propertyr   r   r   r   r   r   r	   r      s    
r   Nc                   C   s   t S r   _active_contextr   r   r   r	   context.   s   r   c                   @   s(   e Zd ZdZdd Zdd Zdd ZdS )	r   z=A Python context for wrapping a cancellable ConcreteFunction.c                 C   s
   || _ d S r   )_cancellation_manager)r   Zcancellation_managerr   r   r	   r
   5   s   
z#CancellationManagerContext.__init__c                 C   s
   | j ad S r   )r   r   r   r   r   r	   	__enter__8   s   
z$CancellationManagerContext.__enter__c                 C   s   d a d S r   r   )r   exc_type	exc_valueexc_tbr   r   r	   __exit__<   s   z#CancellationManagerContext.__exit__N)r   r   r   r   r
   r   r"   r   r   r   r	   r   2   s
    r   )r   Ztensorflow.pythonr   objectr   r   r   r   r   r   r   r	   <module>   s   