§
    ÁÞMhò&  ã                   ó´   — d Z ddlZddlmZmZmZ ddlmZmZm	Z	m
Z
mZ ddlmZmZmZ ddlmZ  G d„ d	e ee¦  «        ¦  «        Z G d
„ deee¬¦  «        ZdS )zKernel Provisioner Classesé    N)ÚABCÚABCMetaÚabstractmethod)ÚAnyÚDictÚListÚOptionalÚUnion)ÚInstanceÚLoggingConfigurableÚUnicodeé   )ÚKernelConnectionInfoc                   ó   — e Zd ZdS )ÚKernelProvisionerMetaN)Ú__name__Ú
__module__Ú__qualname__© ó    úl/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/jupyter_client/provisioning/provisioner_base.pyr   r      s   € € € € € Ø€Dr   r   c                   óŽ  — e Zd ZU dZ edd¬¦  «        Zeed<    edd¬¦  «        Z	e
eef         ed<   i Zeed<   eed	efd
„¦   «         ¦   «         Zed	ee         fd„¦   «         Zed	ee         fd„¦   «         Zeded	dfd„¦   «         Zed&ded	dfd„¦   «         Zed&ded	dfd„¦   «         Zedee         ded	efd„¦   «         Zed&ded	dfd„¦   «         Zd&ded	dfd„Zded	eeef         fd„Zded	dfd„Zd	eeef         fd„Z ded	dfd„Z!d'de"d	e"fd„Z#d(de"d	e"fd!„Z$d"eeef         d	dfd#„Z%d$eeef         d	eeef         fd%„Z&dS ))ÚKernelProvisionerBaseaã  
    Abstract base class defining methods for KernelProvisioner classes.

    A majority of methods are abstract (requiring implementations via a subclass) while
    some are optional and others provide implementations common to all instances.
    Subclasses should be aware of which methods require a call to the superclass.

    Many of these methods model those of :class:`subprocess.Popen` for parity with
    previous versions where the kernel process was managed directly.
    z$jupyter_client.kernelspec.KernelSpecT)Ú
allow_noneÚkernel_specNÚ	kernel_idÚconnection_infoÚreturnc                 ó   — dS )zÙ
        Returns true if this provisioner is currently managing a process.

        This property is asserted to be True immediately following a call to
        the provisioner's :meth:`launch_kernel` method.
        Nr   ©Úselfs    r   Úhas_processz!KernelProvisionerBase.has_process$   s	   € ð 	ˆr   c              ƒ   ó
   K  — dS )zä
        Checks if kernel process is still running.

        If running, None is returned, otherwise the process's integer-valued exit code is returned.
        This method is called from :meth:`KernelManager.is_alive`.
        Nr   r    s    r   ÚpollzKernelProvisionerBase.poll/   ó   è è € ð 	ˆr   c              ƒ   ó
   K  — dS )zó
        Waits for kernel process to terminate.

        This method is called from `KernelManager.finish_shutdown()` and
        `KernelManager.kill_kernel()` when terminating a kernel gracefully or
        immediately, respectively.
        Nr   r    s    r   ÚwaitzKernelProvisionerBase.wait9   s   è è € ð 	ˆr   Úsignumc              ƒ   ó
   K  — dS )z»
        Sends signal identified by signum to the kernel process.

        This method is called from `KernelManager.signal_kernel()` to send the
        kernel process a signal.
        Nr   )r!   r(   s     r   Úsend_signalz!KernelProvisionerBase.send_signalD   r%   r   FÚrestartc              ƒ   ó
   K  — dS )aL  
        Kill the kernel process.

        This is typically accomplished via a SIGKILL signal, which cannot be caught.
        This method is called from `KernelManager.kill_kernel()` when terminating
        a kernel immediately.

        restart is True if this operation will precede a subsequent launch_kernel request.
        Nr   ©r!   r+   s     r   ÚkillzKernelProvisionerBase.killN   s   è è € ð 	ˆr   c              ƒ   ó
   K  — dS )a©  
        Terminates the kernel process.

        This is typically accomplished via a SIGTERM signal, which can be caught, allowing
        the kernel provisioner to perform possible cleanup of resources.  This method is
        called indirectly from `KernelManager.finish_shutdown()` during a kernel's
        graceful termination.

        restart is True if this operation precedes a start launch_kernel request.
        Nr   r-   s     r   Ú	terminatezKernelProvisionerBase.terminate[   s   è è € ð 	ˆr   ÚcmdÚkwargsc              ‹   ó
   K  — dS )zÑ
        Launch the kernel process and return its connection information.

        This method is called from `KernelManager.launch_kernel()` during the
        kernel manager's start kernel sequence.
        Nr   )r!   r1   r2   s      r   Úlaunch_kernelz#KernelProvisionerBase.launch_kerneli   r%   r   c              ƒ   ó
   K  — dS )a"  
        Cleanup any resources allocated on behalf of the kernel provisioner.

        This method is called from `KernelManager.cleanup_resources()` as part of
        its shutdown kernel sequence.

        restart is True if this operation precedes a start launch_kernel request.
        Nr   r-   s     r   ÚcleanupzKernelProvisionerBase.cleanups   ó   è è € ð 	ˆr   c              ƒ   ó
   K  — dS )a‚  
        Allows the provisioner to determine if the kernel's shutdown has been requested.

        This method is called from `KernelManager.request_shutdown()` as part of
        its shutdown sequence.

        This method is optional and is primarily used in scenarios where the provisioner
        may need to perform other operations in preparation for a kernel's shutdown.
        Nr   r-   s     r   Úshutdown_requestedz(KernelProvisionerBase.shutdown_requested   r7   r   c              ‹   óò   K  — |                      dt          j        ¦  «                             ¦   «         }|                     |                      |¦  «        ¦  «         |                      |¦  «         ||d<   |S )a(  
        Perform any steps in preparation for kernel process launch.

        This includes applying additional substitutions to the kernel launch command
        and environment. It also includes preparation of launch parameters.

        NOTE: Subclass implementations are advised to call this method as it applies
        environment variable substitutions from the local environment and calls the
        provisioner's :meth:`_finalize_env()` method to allow each provisioner the
        ability to cleanup the environment variables that will be used by the kernel.

        This method is called from `KernelManager.pre_start_kernel()` as part of its
        start kernel sequence.

        Returns the (potentially updated) keyword arguments that are passed to
        :meth:`launch_kernel()`.
        Úenv)ÚpopÚosÚenvironÚcopyÚupdateÚ/_KernelProvisionerBase__apply_env_substitutionsÚ_finalize_env)r!   r2   r;   s      r   Ú
pre_launchz KernelProvisionerBase.pre_launch‹   sk   è è € ð$ jŠj˜¥¤
Ñ+Ô+×0Ò0Ñ2Ô2ˆØ
Š
4×1Ò1°#Ñ6Ô6Ñ7Ô7Ð7Ø×Ò˜3ÑÔÐØˆˆu‰àˆr   c              ‹   ó
   K  — dS )z¾
        Perform any steps following the kernel process launch.

        This method is called from `KernelManager.post_start_kernel()` as part of its
        start kernel sequence.
        Nr   )r!   r2   s     r   Úpost_launchz!KernelProvisionerBase.post_launch¤   s   è è € ð 	ˆr   c              ƒ   ó6   K  — i }| j         |d<   | j        |d<   |S )aÞ  
        Captures the base information necessary for persistence relative to this instance.

        This enables applications that subclass `KernelManager` to persist a kernel provisioner's
        relevant information to accomplish functionality like disaster recovery or high availability
        by calling this method via the kernel manager's `provisioner` attribute.

        NOTE: The superclass method must always be called first to ensure proper serialization.
        r   r   ©r   r   ©r!   Úprovisioner_infos     r   Úget_provisioner_infoz*KernelProvisionerBase.get_provisioner_info­   s0   è è € ð ,.ÐØ(,¬Ð˜Ñ%Ø.2Ô.BÐÐ*Ñ+ØÐr   rI   c              ƒ   ó>   K  — |d         | _         |d         | _        dS )aç  
        Loads the base information necessary for persistence relative to this instance.

        The inverse of `get_provisioner_info()`, this enables applications that subclass
        `KernelManager` to re-establish communication with a provisioner that is managing
        a (presumably) remote kernel from an entirely different process that the original
        provisioner.

        NOTE: The superclass method must always be called first to ensure proper deserialization.
        r   r   NrG   rH   s     r   Úload_provisioner_infoz+KernelProvisionerBase.load_provisioner_info¼   s(   è è € ð *¨+Ô6ˆŒØ/Ð0AÔBˆÔÐÐr   ç      @Úrecommendedc                 ó   — |S )aE  
        Returns the time allowed for a complete shutdown. This may vary by provisioner.

        This method is called from `KernelManager.finish_shutdown()` during the graceful
        phase of its kernel shutdown sequence.

        The recommended value will typically be what is configured in the kernel manager.
        r   ©r!   rN   s     r   Úget_shutdown_wait_timez,KernelProvisionerBase.get_shutdown_wait_timeÊ   s
   € ð Ðr   ç      $@c                 ó   — |S )zÚ
        Returns the expected upper bound for a kernel (re-)start to complete.
        This may vary by provisioner.

        The recommended value will typically be what is configured in the kernel restarter.
        r   rP   s     r   Úget_stable_start_timez+KernelProvisionerBase.get_stable_start_timeÕ   s
   € ð Ðr   r;   c                 ó´   — | j         j        rI| j         j                             ¦   «                              d¦  «        r|                     dd¦  «         dS dS dS )zþ
        Ensures env is appropriate prior to launch.

        This method is called from `KernelProvisionerBase.pre_launch()` during the kernel's
        start sequence.

        NOTE: Subclasses should be sure to call super()._finalize_env(env)
        ÚpythonÚPYTHONEXECUTABLEN)r   ÚlanguageÚlowerÚ
startswithr<   )r!   r;   s     r   rB   z#KernelProvisionerBase._finalize_envÞ   sk   € ð ÔÔ$ð 	.¨Ô)9Ô)B×)HÒ)HÑ)JÔ)J×)UÒ)UÐV^Ñ)_Ô)_ð 	.ð GŠGÐ&¨Ñ-Ô-Ð-Ð-Ð-ð	.ð 	.ð 	.ð 	.r   Úsubstitution_valuesc                 óÖ   — i }| j         r_ddlm} | j         j        }|                     ¦   «         D ]8\  }}|                     | ||¦  «                             |¦  «        i¦  «         Œ9|S )aq  
        Walks entries in the kernelspec's env stanza and applies substitutions from current env.

        This method is called from `KernelProvisionerBase.pre_launch()` during the kernel's
        start sequence.

        Returns the substituted list of env entries.

        NOTE: This method is private and is not intended to be overridden by provisioners.
        r   )ÚTemplate)r   Ústringr]   r;   Úitemsr@   Úsafe_substitute)r!   r[   Úsubstituted_envr]   Útemplated_envÚkÚvs          r   Ú__apply_env_substitutionsz/KernelProvisionerBase.__apply_env_substitutionsì   sŽ   € ð ˆØÔð 	^Ø'Ð'Ð'Ð'Ð'Ð'ð
 !Ô,Ô0ˆMØ%×+Ò+Ñ-Ô-ð ^ð ^‘1Ø×&Ò&¨¨8¨8°A©;¬;×+FÒ+FÐGZÑ+[Ô+[Ð'\Ñ]Ô]Ð]Ð]ØÐr   )F)rM   )rR   )'r   r   r   Ú__doc__r   r   r   Ú__annotations__r   r   r
   Ústrr   r   Úpropertyr   Úboolr"   r	   Úintr$   r'   r*   r.   r0   r   r4   r6   r9   r   rC   rE   rJ   rL   ÚfloatrQ   rT   rB   rA   r   r   r   r   r      so  € € € € € € ð	ð 	ð  xÐ FÐSWÐXÑXÔX€KÐXÐXÑXØ%, W¨T¸dÐ%CÑ%CÔ%C€IˆuS˜'\Ô"ÐCÐCÑCØ,.€OÐ)Ð.Ð.Ñ.àØð˜Tð ð ð ñ „^ñ „Xðð ð˜H SœMð ð ð ñ „^ðð ð˜H SœMð ð ð ñ „^ðð ð¨ð °ð ð ð ñ „^ðð ð
ð 
 $ð 
°4ð 
ð 
ð 
ñ „^ð
ð ðð  tð ¸ð ð ð ñ „^ðð ð t¨C¤yð ¸Cð ÐDXð ð ð ñ „^ðð ð	ð 	 Tð 	°dð 	ð 	ð 	ñ „^ð	ð
ð 
°ð 
Àð 
ð 
ð 
ð 
ð¨ð °°c¸3°h´ð ð ð ð ð2¨#ð °$ð ð ð ð ð ¨D°°c°¬Nð  ð  ð  ð  ðC¸Dð CÀTð Cð Cð Cð Cð	ð 	°%ð 	À%ð 	ð 	ð 	ð 	ðð °ð À%ð ð ð ð ð.  c¨3 h¤ð .°Dð .ð .ð .ð .ð¸TÀ#ÀsÀ(¼^ð ÐPTÐUXÐZ]ÐU]ÔP^ð ð ð ð ð ð r   r   )Ú	metaclass)rf   r=   Úabcr   r   r   Útypingr   r   r   r	   r
   Útraitlets.configr   r   r   Úconnectr   Útyper   r   r   r   r   ú<module>rs      s  ðØ  Ð  ð 
€	€	€	Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3à CÐ CÐ CÐ CÐ CÐ CÐ CÐ CÐ CÐ Cà *Ð *Ð *Ð *Ð *Ð *ð	ð 	ð 	ð 	ð 	˜G T TÐ*=Ñ%>Ô%>ñ 	ô 	ð 	ðpð pð pð pð pØÐ	Ð(=ðpñ pô pð pð pð pr   