
    &`i                         d dl Z d dlZd dlZd dlZd dlZd dlZd dlmZ d dlm	Z	  ej
        e          ZdZd Z ej                    Zd Zd Ze	dd            Zd	 Zd
 Zd Zd ZdS )    N)build_address)DeveloperAPIpost_mortem_error_uuidc                      	 t          j        d          } t          | d          r| j        dk     rt	                      | S # t
          t          f$ r t                              d           Y d S w xY w)Ndebugpy__version__z1.8.0zModule 'debugpy>=1.8.0' cannot be loaded. Ray Debugpy Debugger will not work without 'debugpy>=1.8.0' installed. Install this module using 'pip install debugpy==1.8.0' )	importlibimport_modulehasattrr   ImportErrorModuleNotFoundErrorlogerror)r   s    d/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/ray/util/debugpy.py_try_import_debugpyr      s    ))44w.. 	 '2E2O2O---   		F	
 	
 	

 tts   >A +A0/A0c                  j    t           t          _        t           t          _        ddl} t           | _        dS )a>  
    This method overrides the breakpoint() function to set_trace()
    so that other threads can reuse the same setup logic.
    This is based on: https://github.com/microsoft/debugpy/blob/ef9a67fe150179ee4df9997f9273723c26687fab/src/debugpy/_vendored/pydevd/pydev_sitecustomize/sitecustomize.py#L87 # noqa: E501
    r   N)	set_tracesys__breakpointhook__breakpointhookbuiltins
breakpoint)__builtin__s    r   _override_breakpoint_hooksr   #   s.     'C"C""""&K    c                     t           5  t                      } | s	 ddd           dS t          j        j        j        j        }|s|                     t          j        j        j        j        df          \  }}t          j        j        j        	                    |           t                              dt          ||                      nt                              d|            ddd           dS # 1 swxY w Y   dS )zk
    This is a thread safe method that ensure that the debugger port
    is open, and if not, open it.
    Nr   zRay debugger is listening on z Ray debugger is already open on )debugger_port_lockr   ray_privateworkerglobal_workerdebugger_portlistennode_ip_addressset_debugger_portr   infor   )r   r"   hostports       r   &_ensure_debugger_port_open_thread_safer)   0   sn    
 I I%'' 	I I I I I I I I
 +9G 	I">>$2BAF LT4 L-??EEEHHP]45N5NPPQQQQHHGGGHHHI I I I I I I I I I I I I I I I I Is   C6CC66C:=C:c                    t                      }|sdS t                       t                       t          j        j        j                                        5  d}t          	                    |           |
                                 ddd           n# 1 swxY w Y   t          	                    d           | t          k    rt                       dS t                       dS )zrInterrupt the flow of the program and drop into the Ray debugger.
    Can be used within a Ray task or actor.
    NzuWaiting for debugger to attach (see https://docs.ray.io/en/latest/ray-observability/ray-distributed-debugger.html)...zDebugger client is connected)r   r)   r   r   r   r    r!   worker_paused_by_debuggerr   r&   wait_for_clientPOST_MORTEM_ERROR_UUID_debugpy_excepthook_debugpy_breakpoint)breakpoint_uuidr   msgs      r   r   r   H   s   
 "##G *,,,    			*	D	D	F	F " "0 	
 	!!!" " " " " " " " " " " " " " " HH+,,,000s   1BBBc                  f    ddl } |                     t          j                    j                   dS )z:
    Drop the user into the debugger on a breakpoint.
    r   N)stop_at_frame)pydevdsettracer   	_getframef_back)r4   s    r   r/   r/   g   s0     MMM
OO#-//"8O99999r   c                     ddl } ddl}|                                } | j                    }|                    |          }|xj        dz  c_        	 t          j                    }|                    ||||           t          j	        |d         |d         |d                    |xj        dz  c_        dS # |xj        dz  c_        w xY w)zD
    Drop the user into the debugger on an unhandled exception.
    r   N      )
	threadingr4   get_global_debuggercurrent_threadset_additional_thread_info
is_tracingr   exc_infostop_on_unhandled_exception
excepthook)r;   r4   py_dbthreadadditional_infor   s         r   r.   r.   p   s     MMM&&((E%Y%''F66v>>O!#())%%PPPuQxq58444""a'""""""a'""""""s   AB7 7C	c                  J    t           j                            dd          dk    S )NRAY_DEBUG_POST_MORTEM01)osenvironget r   r   $_is_ray_debugger_post_mortem_enabledrN      s    :>>13773>>r   c                  *    t          t                    S N)r   r-   rM   r   r   _post_mortemrQ      s    +,,,r   rP   )r	   loggingrJ   r   r;   r   ray._common.network_utilsr   ray.util.annotationsr   	getLogger__name__r   r-   r   Lockr   r   r)   r   r/   r.   rN   rQ   rM   r   r   <module>rX      s%        				 



     



 3 3 3 3 3 3 - - - - - -g!!1     $Y^%% 
' 
' 
'I I I0    <: : :( ( ((? ? ?- - - - -r   