o
    #f                     @   s6   d dl mZ d dlmZmZ G dd deZdgZdS )    )
ContextVar)Context_RuntimeContextc                   @   sP   e Zd ZdZdZdddZdedefdd	Zdefd
dZ	deddf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returnNc                 C   s   t | jt d| _d S )N)default)r   _CONTEXT_KEYr   _current_contextself r   e/home/ubuntu/dev/venv/lib/python3.10/site-packages/mysql/opentelemetry/context/contextvars_context.py__init__   s   z"ContextVarsRuntimeContext.__init__contextc                 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.detach)r   N)__name__
__module____qualname____doc__r	   r   r   objectr   r   r   r   r   r   r   r      s    
	r   N)contextvarsr   #mysql.opentelemetry.context.contextr   r   r   __all__r   r   r   r   <module>   s   
 