
    G)f                     <    d dl mZ d dlmZmZ  G d de      ZdgZy)    )
ContextVar)Context_RuntimeContextc                   H    e Zd ZdZdZddZdedefdZdefdZ	d	eddfd
Z
y)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                 L    t        | j                  t                     | _        y )N)default)r   _CONTEXT_KEYr   _current_contextselfs    l/var/www/html/flask-app/venv/lib/python3.12/site-packages/mysql/opentelemetry/context/contextvars_context.py__init__z"ContextVarsRuntimeContext.__init__   s     *4+<+<gi P    contextc                 8    | j                   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   s     r   attachz ContextVarsRuntimeContext.attach   s     $$((11r   c                 6    | j                   j                         S )z%Returns the current `Context` object.)r   getr   s    r   get_currentz%ContextVarsRuntimeContext.get_current&   s    $$((**r   tokenc                 :    | j                   j                  |       y)zpResets Context to a previous value

        Args:
            token: A reference to a previous Context.
        N)r   reset)r   r   s     r   detachz ContextVarsRuntimeContext.detach*   s     	##E*r   )r	   N)__name__
__module____qualname____doc__r   r   r   objectr   r   r    r   r   r   r      sF     %LQ2g 2& 2+W ++F +t +r   r   N)contextvarsr   #mysql.opentelemetry.context.contextr   r   r   __all__r#   r   r   <module>r'      s$    # H+ +@ '
'r   