U
    4Je                     @   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dZeeddd	Zedd
dZ	ed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+
    Zcurrent_contextN)returnc                 C   s   t | jt d| _d S )N)default)r   _CONTEXT_KEYr   _current_contextself r   S/tmp/pip-unpacked-wheel-7_167w8m/mysql/opentelemetry/context/contextvars_context.py__init__   s    z"ContextVarsRuntimeContext.__init__)contextr   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)tokenr   c                 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)__name__
__module____qualname____doc__r   r   r   objectr   r   r   r   r   r   r   r      s   	r   N)Zcontextvarsr   Z#mysql.opentelemetry.context.contextr   r   r   __all__r   r   r   r   <module>   s    