
    Xh                    z    d Z ddlmZ ddlZddlmZ ddlmZmZ ddl	m
Z
 ddlmZmZ dd	lmZ  G d
 deee      Zy)z7A lab app that runs a sub process for a demo or a test.    )annotationsN)Any)ExtensionAppExtensionAppJinjaMixin)IOLoop   )	LabConfigadd_handlers)Processc                  @    e Zd ZdZdZdZd
dZddZddZddZ	ddZ
y	)
ProcessAppzFA jupyterlab app that runs a separate process and exits on completion.TFc                *    t         j                  dgi fS )zeGet the command and kwargs to run with `Process`.
        This is intended to be overridden.
        z	--version)sys
executableselfs    Q/var/www/html/myenv/lib/python3.12/site-packages/jupyterlab_server/process_app.pyget_commandzProcessApp.get_command   s     ,b00    c                ^    t        j                         j                  | j                         y)zStart the application.N)r   currentadd_callback_run_commandr   s    r   initialize_settingszProcessApp.initialize_settings   s    %%d&7&78r   c                0    t        | j                  |        y)zInitialize the handlers.N)r
   handlersr   s    r   initialize_handlerszProcessApp.initialize_handlers#   s    T]]D)r   c                    | j                         \  }}|j                  d| j                         t        |fi |j	                         }t        j                         j                  || j                         y )Nlogger)	r   
setdefaultlogr   
wait_asyncr   r   
add_future_process_finished)r   commandkwargsfutures       r   r   zProcessApp._run_command'   s]    **,(DHH-+F+668##FD,B,BCr   c                .   	 t        j                         j                          t        j                  |j                                y # t        $ rC}| j                  j                  t        |             t        j                  d       Y d }~y d }~ww xY w)Nr   )
r   r   stopr   exitresult	Exceptionr!   errorstr)r   r'   es      r   r$   zProcessApp._process_finished-   s]    	NN!!#HHV]]_% 	HHNN3q6"HHQKK	s   AA 	B9BBN)returnz tuple[list[str], dict[str, Any]])r0   None)r'   r   r0   r1   )__name__
__module____qualname____doc__load_other_extensionsopen_browserr   r   r   r   r$    r   r   r   r      s,    P  L19*Dr   r   )r5   
__future__r   r   typingr   $jupyter_server.extension.applicationr   r   tornado.ioloopr   r   r	   r
   processr   r   r8   r   r   <module>r>      s0    > " 
  U ! - "'L "r   