
    &`i
                     F   d dl mZmZmZ d dlZded         fdZdddeedef                  deeedef                  eedef                  f         fdZd	ed
eedef                  deeedef                  eedef                  f         fdZded         defdZ	dS )    )ListOptionalTupleNreturnzray.actor.ActorHandlec                  V    	 t          j                    j        S # t          $ r Y dS w xY w)zv
    Get the current actor handle in this worker.
    If this is called in a driver process, it will return None.
    N)rayget_runtime_contextcurrent_actorRuntimeError     r/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/ray/experimental/channel/utils.pyget_self_actorr      s;    
&((66   tts    
((writerreader_and_node_listc                     g }g }|D ]:\  }}|| k    r|                     ||f           #|                     ||f           ;||fS )a\  Split readers into remote and local readers based on writer.

    Args:
        writer: The actor handle of the writer
        reader_and_node_list: List of (reader, node) tuples

    Returns:
        Tuple containing:
            - List of (reader, node) tuples for remote readers
            - List of (reader, node) tuples for local readers
    append)r   r   remote_readerslocal_readersreadernodes         r   split_readers_by_localityr      sm    " NM, 1 1V!!64.1111  &$0000=((r   r   actor_and_node_listc                     g }g }|D ]:\  }}| |k    r|                     ||f           #|                     ||f           ;||fS )a  Split actors into remote and local actors based on node. The local actors will be
    on the same node as the given node. The remote actors will be on a different node.

    Args:
        writer_node: The node of the writer
        actor_and_node_list: List of (actor, node) tuples

    Returns:
        Tuple containing:
            - List of (actor, node) tuples for actors on the same node
            - List of (actor, node) tuples for actors on a different node
    r   )r   r   actors_on_same_nodeactors_on_different_nodeactor
actor_nodes         r   split_actors_by_node_localityr    .   su    $ !0 A Az:&&z':;;;;$++UJ,?@@@@ 888r   r   c                     | | t          j                    j        k    r%t          j                                                    S t          j        | j                            d                     S )zGet the node of the actor.

    Args:
        actor: The actor handle of the actor

    Returns:
        The node of the actor
    Nc                 L    t          j                                                    S )N)r   r	   get_node_id)selfs    r   <lambda>z get_actor_node.<locals>.<lambda>Z   s    S466BBDD r   )r   r	   r
   r#   get__ray_call__remote)r   s    r   get_actor_noder)   L   sj     }!8!:!:!HHH&((44666w%%DD 
 
 	
r   )
typingr   r   r   r   r   strr   r    r)   r   r   r   <module>r,      sW   ( ( ( ( ( ( ( ( ( ( 



!89    )#)u%<c%ABC) &+	,-tE:QSV:V4W/XX) ) ) ):9
9e$;S$@AB9 &+	,-tE:QSV:V4W/XX9 9 9 9<
(#:; 
 
 
 
 
 
 
r   