def get_running_async_lock() -> AsyncContextManager:
    """Get a lock instance from the async library that the current context is running under.

    :return: An instance of the running async library's Lock class.
    :rtype: AsyncContextManager
    :raises: RuntimeError if the current context is not running under an async library.
    """

    try:
        import asyncio

        # Check if we are running in an asyncio event loop.
        asyncio.get_running_loop()
        return asyncio.Lock()
    except RuntimeError as err:
        # Otherwise, assume we are running in a trio event loop if it has already been imported.
        if "trio" in sys.modules:
            import trio  # pylint: disable=networking-import-outside-azure-core-transport

            return trio.Lock()
        raise RuntimeError("An asyncio or trio event loop is required.") from err
Get a lock instance from the async library that the current context is running under.

    :return: An instance of the running async library's Lock class.
    :rtype: AsyncContextManager
    :raises: RuntimeError if the current context is not running under an async library.
    
Solutions/CyberArkAudit/Data Connectors/.python_packages/lib/site-packages/azure/core/utils/_utils.py