+
    uG9j                     *  a  R t0 t R t^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RI	H
t
HtHtHt ^ RIHt ]P                   ! ]4      tRt] ^ k  . t] ^k Rs] ^k ]P,                  ! 4       tR R ltRR	 R
 lltRR R lltR R ltRs] ^k R R ltR# )uc  Long-running command lifecycle management for anaconda-cli-base.

Provides signal handling, shutdown hooks, bounded telemetry flush, and a
process-exit watchdog for CLI commands that block indefinitely (e.g., servers).

Short-lived commands do not need this module — they exit cleanly via
``_after_command`` which handles telemetry flush automatically.
N)	FrameType)AnyCallableListOptional)	telemetryg      $@Fc                :    V ^8  d   QhR\         . R3,          RR/# )   hookNreturnr   )formats   ";lib/python3.14/site-packages/anaconda_cli_base/lifecycle.py__annotate__r      s#     	 	"d(!3 	 	    c                0    \         P                  V 4       R# )u  Register a callable to run when shutdown is triggered.

Hooks run in registration order. They should be fast (milliseconds)
and non-blocking — use them to set events, close pipes, etc.

Not idempotent: each call appends another hook. Register a given
hook once (typically at startup).
N)_hooksappend)r
   s   &r   register_shutdown_hookr      s     MM$r   c                >    V ^8  d   QhR\         \        ,          RR/# r	   signumr   Nr   int)r   s   "r   r   r   +   s"     U UXc] Ud Ur   c                   \         ;_uu_ 4        \        '       d    RRR4       R# RsRRR4       \        P                  ! \        \
        V 3R7      pRVn        VP                  4        \         F  p V! 4        K  	   \        P                  ! RR7       R#   + '       g   i     Lx; i  \         d    \        P                  RTRR7        Kb  i ; i  \         d    \        P                  RRR7        R# i ; i)	up  Trigger the shutdown sequence. Idempotent.

1. Starts the watchdog timer FIRST (so nothing below can prevent it).
2. Runs all registered hooks in order (each wrapped in try/except).
3. Calls shutdown_telemetry with a 2-second bound.

Does NOT call os._exit itself — lets normal unwinding continue.
The watchdog fires os._exit(128 + signum) only if unwinding stalls.
NT)argszShutdown hook %r failedexc_infog       @)timeout_secondsz-Telemetry shutdown in trigger_shutdown failed)_trigger_lock
_triggered	threadingTimerWATCHDOG_DEADLINE_SECS_force_exitdaemonstartr   	Exceptionloggerdebugr   shutdown_telemetry)r   timerr
   s   &  r   trigger_shutdownr,   +   s     
: 
 
 
 OO2KviPEEL	KKM 	IF U$$S9% 
  	ILL2D4LH	I
  UDtTUs4   BB4B, C B)	,#CC"C<;C<c                >    V ^8  d   QhR\         \        ,          RR/# r   r   )r   s   "r   r   r   M   s     : : : :r   c                X    \         P                  ! V e   ^V ,           4       R# ^4       R# )z?Last-resort process termination. Fires from the watchdog timer.N)os_exit)r   s   &r   r$   r$   M   s    HHV/S6\9S9r   c                0    V ^8  d   QhR\         R\         /# )r	   funcr   r   )r   s   "r   r   r   R   s      x H r   c                L   a  \         P                  ! S 4      R V 3R ll4       pV# )aC  Decorator marking a CLI command as long-running.

On invocation, installs SIGTERM and SIGINT handlers that call
trigger_shutdown(signum). The original signal behavior (KeyboardInterrupt
for SIGINT) is preserved after trigger_shutdown runs.

Idempotent: re-applying is a no-op. Windows-safe (guards on signal
availability).
c                <    V ^8  d   QhR\         R\         R\         /# )r	   r   kwargsr   )r   )r   s   "r   r   "long_running.<locals>.__annotate__^   s!     % %s %c %c %r   c                  (   < \        4        S! V / VB # N)_install_signal_handlers)r   r5   r2   s   *,r   wrapperlong_running.<locals>.wrapper]   s     "T$V$$r   )	functoolswraps)r2   r:   s   f r   long_runningr>   R   s'     __T% % Nr   c                    V ^8  d   QhRR/# )r	   r   N )r   s   "r   r   r   h   s     I I$ Ir   c                 R   \         '       d   R# R R lp  \        \        R4      '       d&   \        P                  ! \        P                  V 4       \        P                  ! \        P                  V 4       Rs R#   \
        \        3 d    \        P                  RRR7        R# i ; i)z,Install SIGTERM/SIGINT handlers. Idempotent.Nc                J    V ^8  d   QhR\         R\        \        ,          RR/# )r	   r   framer   N)r   r   r   )r   s   "r   r   ._install_signal_handlers.<locals>.__annotate__n   s&     $ $ $HY,? $D $r   c                 R    \        V 4       V \        P                  8X  d   \        hR # r8   )r,   signalSIGINTKeyboardInterrupt)r   rC   s   &&r   _signal_handler1_install_signal_handlers.<locals>._signal_handlern   s!     V]]"## #r   SIGTERMTz!Could not install signal handlersr   )	_handlers_installedhasattrrF   rK   rG   OSError
ValueErrorr(   r)   )rI   s    r   r9   r9   h   sv     $I69%%MM&../:fmm_5"Z  I84HIs   A"A: :(B&%B&c                    V ^8  d   Qh/ ^ \         9   d
   \        ;R&   ^\         9   d   \        \        . R3,          ,          ;R&   ^\         9   d
   \        ;R&   ^\         9   d
   \        ;R&   # )r	   r#   Nr   r    rL   )__conditional_annotations__floatr   r   bool)r   s   "r   r   r      sd      * % $ $+2 & %Xb$h  %34  D 5H " !T !Ir   r8   )rQ   __doc__r<   loggingr/   rF   r!   typesr   typingr   r   r   r   anaconda_cli_baser   	getLogger__name__r(   r#   r   r    Lockr   r   r,   r$   r>   rL   r9   r   )rQ   s   @r   <module>r\      s      	    0 0 '			8	$ $  $F $& %
  	UD:
& "  !Ir   