
    h-                         S SK r S SKrS SKrS SKrS SKrS SKJr  S SKJrJ	r	  S SK
JrJrJr  \R                  " 5       r\" 5       r\R$                  " 5       r " S S\	R(                  5      rS rS rS	 rg)
    N)common)logutil)
components	launchersserversc                      ^  \ rS rSrSr\R                  " S5      rU 4S jrS r	S r
S rS rS	 rSS
 jrSS jrS rSrU =r$ )Session   zA debug session involving a client, an adapter, a launcher, and a debug server.

The client and the adapter are always present, and at least one of launcher and debug
server is present, depending on the scenario.
   c                 P  >^  SSK Jn  [        TT ]  5         [        R
                  " 5       T l        [        T R                  5      T l	        [        R                  " T R                  5      T l        [        R                  " T UR                  5      T l         [        R                  " T [         R"                  5      T l         [        R                  " T [&        R(                  5      T l         S T l         S T l         0 T l         ST l         T =R4                  U 4S j/-  sl        g )Nr   )clientsFc                  $   > TR                  5       $ N)notify_changed)_selfs    kC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\debugpy/adapter/sessions.py<lambda>"Session.__init__.<locals>.<lambda>@   s    d&9&9&;    )debugpy.adapterr   super__init__	threadingRLocklocknext_counterid	Condition_changed_conditionr   missingClientclientr   Launcherlauncherr   Serverserverno_debugpiddebug_optionsis_finalizing	observers)r   r   	__class__s   ` r   r   Session.__init__   s    +OO%	t}}%"+"5"5dii"@ ((w~~>3"**41C1CD	 !((w~~>	 21I"2;<<r   c                 "    SU R                    S3$ )NzSession[]r    r   s    r   __str__Session.__str__B   s    $''!$$r   c                 :    U R                   R                  5         U $ )z&Lock the session for exclusive access.)r   acquirer4   s    r   	__enter__Session.__enter__E   s    		r   c                 8    U R                   R                  5         g)zUnlock the session.N)r   release)r   exc_type	exc_valueexc_tbs       r   __exit__Session.__exit__J   s    		r   c                     [            [        R                  U 5        [        R	                  5         S S S 5        g ! , (       d  f       g = fr   )_lock	_sessionsadd_sessions_changedsetr4   s    r   registerSession.registerN   s'    MM$!!# UUs	   *:
Ac                    U    U R                   R                  5         S S S 5        U R                  U R                  U R                  4n[        S U 5       5      (       aZ  [           U [        ;   a@  [        R                  " SU 5        [        R                  U 5        [        R                  5         S S S 5        g g ! , (       d  f       N= f! , (       d  f       g = f)Nc              3   ^   #    U  H#  o(       + =(       d    UR                   (       + v   M%     g 7fr   )is_connected).0coms     r   	<genexpr>)Session.notify_changed.<locals>.<genexpr>Z   s!     E*3w.c....*s   +-z{0} has ended.)r"   
notify_allr%   r'   r)   allrC   rD   r   inforemoverF   rG   )r   r   s     r   r   Session.notify_changedS   s    ##..0 
 [[$--<
E*EEE9$HH-t4$$T*%))+	  F T s   B;&AC;
C	
Cc                 ^  ^ ^^ U UU4S jmSTl         Tb,  [        R                  " TSS9nSUl        UR	                  5         T    U" 5       (       dC  TR                   (       a
   SSS5        gT R
                  R                  5         U" 5       (       d  MC   SSS5        g! , (       d  f       g= f)a   Waits until predicate() becomes true.

The predicate is invoked with the session locked. If satisfied, the method
returns immediately. Otherwise, the lock is released (even if it was held
at entry), and the method blocks waiting for some attribute of either self,
self.client, self.server, or self.launcher to change. On every change, session
is re-locked and predicate is re-evaluated, until it is satisfied.

While the session is unlocked, message handlers for components other than
the one that is waiting can run, but message handlers for that one are still
blocked.

If timeout is not None, the method will unblock and return after that many
seconds regardless of whether the predicate was satisfied. The method returns
False if it timed out, and True otherwise.
c                  `   > [         R                  " T5        STl        T R                  5         g )NT)timesleep	timed_outr   )r   timeoutwait_for_timeouts   r   r\   *Session.wait_for.<locals>.wait_for_timeouts   s$    JJw)-&!r   FNzSession.wait_for() timeout)targetnameT)rZ   r   Threaddaemonstartr"   wait)r   	predicater[   threadr\   s   ` ` @r   wait_forSession.wait_fora   s    $	"
 &+"%%'.JF !FMLLNkk#--  T '',,.  kk  TTs   B,&BB
B,c                 `   U R                   (       a  gSU l         [        R                  " SX5        Uc  [        U R                  5      n U R                  X5        [        R                  " SU 5        g! [         a0    [        R                  " SU 5        [        R                  " S5         NQf = f)a  Finalizes the debug session.

If the server is present, sends "disconnect" request with "terminateDebuggee"
set as specified request to it; waits for it to disconnect, allowing any
remaining messages from it to be handled; and closes the server channel.

If the launcher is present, sends "terminate" request to it, regardless of the
value of terminate; waits for it to disconnect, allowing any remaining messages
from it to be handled; and closes the launcher channel.

If the client is present, sends "terminated" event to it.

If terminate_debuggee=None, it is treated as True if the session has a Launcher
component, and False otherwise.
NTz{0}; finalizing {1}.z Fatal error while finalizing {0}r   z{0} finalized.)
r-   r   rS   boolr'   	_finalize	Exceptionswallow_exceptionos_exit)r   whyterminate_debuggees      r   finalizeSession.finalize   s    " !'3%!%dmm!4	NN33 	!4(  	 !!"DdKHHQK		s   
A3 37B-,B-c                 	  ^  [         R                  " 5         T R                  (       a  T R                  R                  (       aw  U(       aG  T R                  (       a6  T R                  R                  (       a  T R                  R                  5         O) T R                  R                  R                  SSU05        T R                  R                  5         T R                  (       GaS  T R                  R                  (       Ga7  T R                  (       az  T R                  R                  R                  (       dU  [        R                  " ST 5        T R                  U 4S j[        R                   S9(       d  [        R"                  " ST 5        T R                  (       a%  T R                  R                  R                  (       d  T R                  R                  5         [        R                  " ST T R                  5        T R                  U 4S j5         T R                  R                  R%                  5         T R(                  (       Ga  T R(                  R                  (       aI  0 nT R(                  R*                  (       a  S	US
'    T R(                  R                  R-                  SU5        T R(                  R.                  Gb  T R(                  R.                  R0                  S:X  Gap  T R                  (       a&  T R                  R                  R                  (       Gd8  [         R2                  " 5         [        R                  " S5        [5        5       nT R                  (       a<  T R                  R6                  b%  UR9                  T R                  R6                  5         [         R:                  " 5        Vs/ s H  nUR6                  U;  d  M  UPM     nn[=        U5      (       d  g U He  n[        R                  " SU5         [>        R@                  " UR6                  [B        RD                  5        UR9                  UR6                  5        Mg     M  g g g g ! [         a     GNf = f! [         a    [        R&                  " 5          GNYf = f! [         a     GNf = fs  snf ! [         a    [        R&                  " SU5         Nf = f)N
disconnectterminateDebuggeez!{0} waiting for "exited" event...c                  4   > T R                   R                  S L$ r   )r'   	exit_coder4   s   r   r   #Session._finalize.<locals>.<lambda>   s    DMM334?r   )r[   z){0} timed out waiting for "exited" event.z${0} waiting for {1} to disconnect...c                  :   > T R                   R                  (       + $ r   )r'   rL   r4   s   r   r   rx      s    dmm&@&@"@r   Trestart
terminatedlaunchz>"launch" session ended - killing remaining debuggee processes.zKilling {0}zFailed to kill {0})#r   dont_wait_for_first_connectionr)   rL   r'   rp   channelrequestrk   detach_from_session
connectionprocess_replacedr   rS   rf   r   PROCESS_EXIT_TIMEOUTwarningcloserl   r%   restart_requested
send_eventstart_requestcommandstop_servingrG   r+   rE   connectionslenrm   killsignalSIGTERM)r   ro   rp   bodypids_killedconnconnss   `      r   rj   Session._finalize   sa    	..0;;{{''%$--DMM<V<V MM446++33(+>@R*S
 KK++-===T]]777 {{4;;#9#9#J#J<dC}}?"77 %  KK KTR KKDKK$:$:$K$K002 HH;T4==QMM@A(%%++- ;;;{{'' ;;00&*DOKK''22<F
 ))5KK--55A)?)?)P)P)P$$&T "e==T]]%6%6%BOODMM$5$56 %,$7$7$9$9D88;6 $9  
 u:: %5NGGDHHfnn= $1 !&  *Q B 6 I % B  (%%'( ! &  ) N112FMNsT   (Q $Q0 	&R =R'R'/R,
Q-,Q-0RR
R$#R$,!SS)
r"   r%   r,   r    r-   r'   r   r*   r+   r)   r   )__name__
__module____qualname____firstlineno____doc__	itertoolscountr   r   r5   r9   r@   rH   r   rf   rq   rj   __static_attributes____classcell__)r/   s   @r   r
   r
      sO     q!H"=H%
$
,$L!)F`2 `2r   r
   c                 z   ^  [            [        U 4S j[         5       S 5      sS S S 5        $ ! , (       d  f       g = f)Nc              3   J   >#    U  H  oR                   T:X  d  M  Uv   M     g 7fr   r+   )rM   sessionr+   s     r   rO   get.<locals>.<genexpr>  s     LI9KWWIs   #	#)rC   r   rD   r   s   `r   getr     s     	LILdS 
s   ,
:c                       [            [        [        5      (       d
   SSS5        g[        R	                  5         SSS5        [        R                  5         MW  ! , (       d  f       N$= f)znBlocks until all sessions have ended.

A session ends when all components that it manages disconnect from it.
N)rC   r   rD   rF   clearrc    r   r   wait_until_endedr     sI    
 y>> U ##%  	  Us   AA
A'c                      [         (       d  g [        [         S S9S   n U R                  nUb  UR                  5         g g )Nc                     U R                   $ r   r3   )r   s    r   r    report_sockets.<locals>.<lambda>"  s    GJJr   )keyr   )rD   sortedr%   report_sockets)r   r%   s     r   r   r     s<    9Y$>?BG^^F r   )r   rm   r   r   rX   debugpyr   debugpy.commonr   r   r   r   r   r   r   rC   rG   rD   EventrF   
Observabler
   r   r   r   r   r   r   <module>r      sg   
  	     $ : : 	E	OO% u2doo u2pT

! r   