
    "e                     .    d  Z ddZd d d fdZddZy)c                 f    t        | d      r| j                         S | j                  j                  S )Nmain_thread)hasattrr   	_shutdownim_self)	threadings    H/usr/lib/python3/dist-packages/pydevd_attach_to_process/attach_script.pyget_main_thread_instancer	      s/    y-($$&& ""***    Nc                    ddl }ddl}|j                         }g }|j                         D ]  \  }}|j                  |j                  }|j                  |j
                  j                  |j                  j                        }|j                  d      r|dd }|j                  j                  |fdv r|dfc S |j                  j                  dk(  s|j                  j                  d      d	k(  r|j                  d|       |j                  |        t        |      dkD  rct        |      d
k(  r|d   dfS | |v r|j!                  |        | |v rt        |      d
k(  r|d   dfS t        |      d
kD  r|d   d|d|d   dfS y)z
    :param unlikely_thread_id:
        Pass to mark some thread id as not likely the main thread.

    :return tuple(thread_id, critical_warning)
        N)z.pycz.pyo))_run_module_as_mainrunpy.py)r   z<frozen runpy>)run_module_as_mainr   )
run_moduler   )run_pathr    z<module>__name____main__   zMultiple thread ids found (z%). Choosing main thread id randomly (z).)Nz"Unable to discover main thread id.)sysos_current_framesitemsf_backpathbasenamef_codeco_filenameendswithco_name	f_globalsgetinsertappendlenremove)unlikely_thread_idr   r   current_framespossible_thread_idsthread_identframer   s           r   get_main_thread_idr-      s    ((*N-335 5ell&LLE ll& 77##ELL$<$<=-.}HLL  (+ 0   ##<<:-"":.*<#**1l;  &&|495< !#"#q(&q)2-- $77&&'9: !$77 "#q(&q)2--$%)&q)')<Q)?AA A
 6r
   c                      y N )msgs    r   <lambda>r2   J   s    r
   c                    dd l }dd l}	 |j                  5  t        |      }|j                  dk(  r.t        |d      r|j                         }n|j                         }nd }t        |      \  }}|d}	t        ||	      sd}	t        ||	      sJ |t        ||	      k7  r{|j                         |_        |j                  j                          |j                  j                  t        ||	      d        t        ||	|       ||j                  t        ||	      <   d d d         | d       r |d|       y y # 1 sw Y    xY w#   |d       Y y xY w)	Nr   win32
_get_ident_ident_Thread__identzThe threading module was not imported by user code in the main thread. The debugger will attempt to work around https://bugs.python.org/issue37416.zXIssue found when debugger was trying to work around https://bugs.python.org/issue37416:
zError patching main thread id.)r   r   _active_limbo_lockr	   platformr   r5   	get_identr-   getattr_allocate_lock_tstate_lockacquire_activepopsetattr)
on_warnon_exceptionon_criticalr   r   main_thread_instancer(   main_thread_idcritical_warningmain_thread_id_attrs
             r   fix_main_thread_idrI   J   s|    ,7)) "	q#;I#F ||w& 9l3)2)=)=)?&)2)<)<)>&%)"/ABT/U,N,)&.#35HI*:'"#79LMMM!W-ACV%WW 9B8P8P8R(5(55==? %%))'2FH[*\^bc02E~V\pI%%g.BDW&XYE"	qL 	  f  	g  zJ  L  M Q"	q "	qT756s#   E DD8E 8E=E 
Ec           
         	 dd l }d|j                  v}|rd }d }d }t        |||       nddlm}	 |	j                  d       |rdd	lm}
 ||
j                  _	        |rdd	lm}
 ||
j                  _
        dd l}d |j                  _        |j                         }||j                  d
       |j!                  | |dddd
d
d
       y #  dd l}|j%                          Y y xY w)Nr   r   c                 2    ddl m} |j                  |        y Nr   	pydev_log)_pydev_bundlerN   warnr1   rN   s     r   rB   zattach.<locals>.on_warn   s    3s#r
   c                 2    ddl m} |j                  |        y rL   )rO   rN   	exceptionrQ   s     r   rC   zattach.<locals>.on_exception   s    3##C(r
   c                 2    ddl m} |j                  |        y rL   )rO   rN   criticalrQ   s     r   rD   zattach.<locals>.on_critical   s    3""3'r
   )rB   rC   rD   rM   z6The threading module is already imported by user code.)pydevd_defaultsF)waitT)porthoststdoutToServerstderrToServeroverwrite_prev_tracesuspendtrace_only_current_threadpatch_multiprocessing)r   modulesrI   rO   rN   debug_pydevd_bundlerV   PydevdCustomizationDEFAULT_PROTOCOL
DEBUG_MODEpydevdSetupHoldersetupget_global_debugger#dispose_and_kill_all_pydevd_threadssettrace	traceback	print_exc)rX   rY   protocol
debug_moder   fix_main_threadrB   rC   rD   rN   rV   rf   py_dbrl   s                 r   attachrr      s    7%S[[8$)( w\Wbc 0OOTU6CKO//@6=GO//: $( **,5555A 	!%&+"' 	 		
s   CC
 
C"r/   )r   r   )r	   r-   rI   rr   r0   r
   r   <module>rs      s%   +;6|  /_Zi 77t8r
   