
    Rmj                        d Z ddlmZ ddZdS )zBPrivate helpers for synchronizing Python and native scope context.    )annotationsreturnNonec                     ddl } | j                            d          }||                     |           dS |                                 rdS |                                  dS )a  Ensure the current Python context's stack is active in the native runtime.

    A ``ContextVar`` owns the stack for asyncio tasks. Native code uses a
    thread-local fallback outside its Tokio tasks, so concurrent Python tasks
    must re-synchronize that fallback before each context-sensitive call.
    Explicit worker-thread bindings remain untouched when no ``ContextVar`` is
    present.
    r   N)
nemo_relay_scope_stack_varget_sync_thread_scope_stack_native_scope_stack_activeget_scope_stack)r   stacks     [/home/thesage/.hermes/hermes-agent/venv/lib/python3.11/site-packages/nemo_relay/_context.pyensure_scope_stackr   	   sv     '++D11E++E222,,..          N)r   r   )__doc__
__future__r   r    r   r   <module>r      s>    I H " " " " " "! ! ! ! ! !r   