o
    3Ih%                     @  sF   d dl mZ d dlmZmZ d dlmZmZ G dd deZdgZ	dS )    )annotations)
ContextVarToken)Context_RuntimeContextc                   @  s<   e Zd ZdZdZdddZdd
dZdddZdddZdS )ContextVarsRuntimeContextzAn implementation of the RuntimeContext interface which wraps ContextVar under
    the hood. This is the preferred implementation for usage with Python 3.5+
    current_contextreturnNonec                 C  s   t | jt d| _d S )N)default)r   _CONTEXT_KEYr   _current_contextself r   i/home/air/sanwanet/gpt-api/venv/lib/python3.10/site-packages/opentelemetry/context/contextvars_context.py__init__   s   z"ContextVarsRuntimeContext.__init__contextr   Token[Context]c                 C  s   | j |S )zSets the current `Context` object. Returns a
        token that can be used to reset to the previous `Context`.

        Args:
            context: The Context to set.
        )r   set)r   r   r   r   r   attach"   s   z ContextVarsRuntimeContext.attachc                 C  s
   | j  S )z%Returns the current `Context` object.)r   getr   r   r   r   get_current+   s   
z%ContextVarsRuntimeContext.get_currenttokenc                 C  s   | j | dS )zpResets Context to a previous value

        Args:
            token: A reference to a previous Context.
        N)r   reset)r   r   r   r   r   detach/   s   z ContextVarsRuntimeContext.detachN)r	   r
   )r   r   r	   r   )r	   r   )r   r   r	   r
   )	__name__
__module____qualname____doc__r   r   r   r   r   r   r   r   r   r      s    


	r   N)

__future__r   contextvarsr   r   opentelemetry.context.contextr   r   r   __all__r   r   r   r   <module>   s
   
"