
    7|hM                        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y)    )annotationsN)Enum)TYPE_CHECKINGAnyCallable)ResponseFutureSessionc                   K   t        j                         j                          | |i |dfd}dfd}j                  ||        d{   S 7 w)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.
    c                Z    j                  j                  j                                y N)call_soon_threadsafe
set_resultresult)_asyncio_futureloopresponse_futures    f/var/www/html/test/engine/venv/lib/python3.12/site-packages/langchain_community/utilities/cassandra.pysuccess_handlerz0wrapped_response_future.<locals>.success_handler   s"    !!.";";_=S=S=UV    c                >    j                  j                  |        y r   )r   set_exception)excr   r   s    r   error_handlerz.wrapped_response_future.<locals>.error_handler   s    !!.">">Dr   N)r   r   returnNone)r   BaseExceptionr   r   )asyncioget_event_loopcreate_futureadd_callbacks)funcargskwargsr   r   r   r   r   s        @@@r   wrapped_response_futurer%      s^      !!#D'')ND+F+OWE !!/=As   AAAAc                L   K   t        | j                  |fi | d{   S 7 w)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)sessionqueryr$   s      r   aexecute_cqlr*   &   s&      ))>)>PPPPPs   $"$c                      e Zd ZdZdZdZy)	SetupMode         N)__name__
__module____qualname__SYNCASYNCOFF r   r   r,   r,   4   s    DE
Cr   r,   )r"   zCallable[..., ResponseFuture]r#   r   r$   r   r   r   )r(   r	   r)   strr$   r   r   r   )
__future__r   r   enumr   typingr   r   r   cassandra.clusterr   r	   r%   r*   r,   r6   r   r   <module>r<      sQ    "   / /9 
' 03 ?B  6Q r   