
    NgM                    z    d dl mZ d dlZd dlmZ d dlmZmZmZ erd dl	m
Z
mZ ddZddZ G d de          ZdS )    )annotationsN)Enum)TYPE_CHECKINGAnyCallable)ResponseFutureSessionfuncCallable[..., ResponseFuture]argsr   kwargsreturnc                   K   t          j                                                     | |i |d
fd}dfd}                    ||            d	{V S )a;  Wrap a Cassandra response future in an asyncio future.

    Args:
        func: The Cassandra function to call.
        *args: The arguments to pass to the Cassandra function.
        **kwargs: The keyword arguments to pass to the Cassandra function.

    Returns:
        The result of the Cassandra function.
    _r   r   Nonec                b                         j                                                   d S N)call_soon_threadsafe
set_resultresult)r   asyncio_futureloopresponse_futures    c/var/www/html/ai-engine/env/lib/python3.11/site-packages/langchain_community/utilities/cassandra.pysuccess_handlerz0wrapped_response_future.<locals>.success_handler   s.    !!.";_=S=S=U=UVVVVV    excBaseExceptionc                >                         j        |            d S r   )r   set_exception)r   r   r   s    r   error_handlerz.wrapped_response_future.<locals>.error_handler   s"    !!.">DDDDDr   N)r   r   r   r   )r   r   r   r   )asyncioget_event_loopcreate_futureadd_callbacks)r
   r   r   r   r!   r   r   r   s        @@@r   wrapped_response_futurer&      s       !##D''))NdD+F++OW W W W W W W WE E E E E E E !!/=AAAr   sessionr	   querystrc                8   K   t          | j        |fi | d{V S )a  Execute a CQL query asynchronously.

    Args:
        session: The Cassandra session to use.
        query: The CQL query to execute.
        kwargs: Additional keyword arguments to pass to the session execute method.

    Returns:
        The result of the query.
    N)r&   execute_async)r'   r(   r   s      r   aexecute_cqlr,   &   s5       ))>PPPPPPPPPPPr   c                      e Zd ZdZdZdZdS )	SetupMode         N)__name__
__module____qualname__SYNCASYNCOFF r   r   r.   r.   4   s        DE
CCCr   r.   )r
   r   r   r   r   r   r   r   )r'   r	   r(   r)   r   r   r   r   )
__future__r   r"   enumr   typingr   r   r   cassandra.clusterr   r	   r&   r,   r.   r8   r   r   <module>r=      s    " " " " " "        / / / / / / / / / / :99999999       6Q Q Q Q         r   