ó
    Ù^íhò&  ã                   óš   • S r SSKrSSKJrJrJr  SSKJrJrJ	r	J
r
Jr  SSKJrJrJr  SSKJr   " S S	\\" \5      5      r " S
 S\\\S9rg)zKernel Provisioner Classesé    N)ÚABCÚABCMetaÚabstractmethod)ÚAnyÚDictÚListÚOptionalÚUnion)ÚInstanceÚLoggingConfigurableÚUnicodeé   )ÚKernelConnectionInfoc                   ó   • \ rS rSrSrg)ÚKernelProvisionerMetaé   © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__static_attributes__r   ó    Úf/home/james-whalen/.local/lib/python3.13/site-packages/jupyter_client/provisioning/provisioner_base.pyr   r      s   † Úr   r   c                   ó>  • \ rS rSr% Sr\" SSS9r\\S'   \	" SSS9r
\\\	4   \S'   0 r\\S	'   \\S
\4S j5       5       r\S
\\   4S j5       r\S
\\   4S j5       r\S\S
S4S j5       r\S%S\S
S4S jj5       r\S%S\S
S4S jj5       r\S\\   S\S
\4S j5       r\S%S\S
S4S jj5       rS%S\S
S4S jjrS\S
\\\4   4S jrS\S
S4S jr S
\\\4   4S jr!S\S
S4S jr"S&S\#S
\#4S jjr$S'S\#S
\#4S jjr%S \\\4   S
S4S! jr&S"\\\4   S
\\\4   4S# jr'S$r(g)(ÚKernelProvisionerBaseé   aÇ  
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                 ó   • g)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_processÚ!KernelProvisionerBase.has_process$   s   € ð 	r   c              ƒ   ó   #   • g7f)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   ÚpollÚKernelProvisionerBase.poll/   ó
   é € ð 	ùó   ‚c              ƒ   ó   #   • g7f)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   ÚwaitÚKernelProvisionerBase.wait9   s
   é € ð 	ùr,   Úsignumc              ƒ   ó   #   • g7f)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%   r0   s     r   Úsend_signalÚ!KernelProvisionerBase.send_signalD   r+   r,   Úrestartc              ƒ   ó   #   • g7f)a  
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%   r4   s     r   ÚkillÚKernelProvisionerBase.killN   s
   é € ð 	ùr,   c              ƒ   ó   #   • g7f)aq  
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   r6   s     r   Ú	terminateÚKernelProvisionerBase.terminate[   s
   é € ð 	ùr,   ÚcmdÚkwargsc              ‹   ó   #   • g7f)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%   r<   r=   s      r   Úlaunch_kernelÚ#KernelProvisionerBase.launch_kerneli   r+   r,   c              ƒ   ó   #   • g7f)zú
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   r6   s     r   ÚcleanupÚKernelProvisionerBase.cleanups   ó
   é € ð 	ùr,   c              ƒ   ó   #   • g7f)aR  
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   r6   s     r   Úshutdown_requestedÚ(KernelProvisionerBase.shutdown_requested   rD   r,   c              ‹   óÔ   #   • UR                  S[        R                  5      R                  5       nUR	                  U R                  U5      5        U R                  U5        X!S'   U$ 7f)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%   r=   rI   s      r   Ú
pre_launchÚ KernelProvisionerBase.pre_launch‹   sU   é € ð$ j‰j˜¤§
¡
Ó+×0Ñ0Ó2ˆØ
‰
4×1Ñ1°#Ó6Ô7Ø×Ñ˜3ÔØˆu‰àˆùs   ‚A&A(c              ‹   ó   #   • g7f)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%   r=   s     r   Úpost_launchÚ!KernelProvisionerBase.post_launch¤   s
   é € ð 	ùr,   c              ƒ   óN   #   • 0 nU R                   US'   U R                  US'   U$ 7f)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_infoÚ*KernelProvisionerBase.get_provisioner_info­   s4   é € ð ,.ÐØ(,¯©Ð˜Ñ%Ø.2×.BÑ.BÐÐ*Ñ+ØÐùs   ‚#%rY   c              ƒ   ó4   #   • US   U l         US   U l        g7f)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!   NrW   rX   s     r   Úload_provisioner_infoÚ+KernelProvisionerBase.load_provisioner_info¼   s!   é € ð *¨+Ñ6ˆŒØ/Ð0AÑBˆÕùs   ‚Úrecommendedc                 ó   • U$ )a  
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%   r_   s     r   Úget_shutdown_wait_timeÚ,KernelProvisionerBase.get_shutdown_wait_timeÊ   s
   € ð Ðr   c                 ó   • U$ )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   ra   s     r   Úget_stable_start_timeÚ+KernelProvisionerBase.get_stable_start_timeÕ   s
   € ð Ðr   rI   c                 óÒ   • U R                   R                  (       aL  U R                   R                  R                  5       R                  S5      (       a  UR	                  SS5        ggg)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Ú
startswithrJ   )r%   rI   s     r   rP   Ú#KernelProvisionerBase._finalize_envÞ   sS   € ð ×Ñ×$×$¨×)9Ñ)9×)BÑ)B×)HÑ)HÓ)J×)UÑ)UÐV^×)_Ñ)_ð G‰GÐ&¨Õ-ð *`Ð$r   Úsubstitution_valuesc                 óä   • 0 nU R                   (       a\  SSKJn  U R                   R                  nUR	                  5        H,  u  pVUR                  XS" U5      R                  U5      05        M.     U$ )aA  
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   Ústringrp   rI   ÚitemsrN   Úsafe_substitute)r%   rn   Úsubstituted_envrp   Útemplated_envÚkÚvs          r   Ú__apply_env_substitutionsÚ/KernelProvisionerBase.__apply_env_substitutionsì   sf   € ð ˆØ××Ý'ð
 !×,Ñ,×0Ñ0ˆMØ%×+Ñ+Ö-‘Ø×&Ñ&¨¨8°A«;×+FÑ+FÐGZÓ+[Ð'\Ö]ñ .àÐr   )r!   r    )F)g      @)g      $@))r   r   r   r   Ú__doc__r   r   r   Ú__annotations__r   r    r
   Ústrr!   r   Úpropertyr   Úboolr&   r	   Úintr)   r.   r2   r7   r:   r   r?   rB   rF   r   rQ   rT   rZ   r]   Úfloatrb   re   rP   rO   r   r   r   r   r   r      s*  ‡ ñ	ñ  Ð FÐSWÑX€KÓXÙ%,¨T¸dÑ%C€IˆuS˜'\Ñ"ÓCØ,.€OÐ)Ó.àØð˜Tó ó ó ðð ð˜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¨3 h¡ð .°Dô .ð¸TÀ#ÀsÀ(¹^ð ÐPTÐUXÐZ]ÐU]ÑP^÷ r   r   )Ú	metaclass)rz   rK   Úabcr   r   r   Útypingr   r   r   r	   r
   Útraitlets.configr   r   r   Úconnectr   Útyper   r   r   r   r   Ú<module>r‡      sK   ðÙ  ó 
ß ,Ñ ,ß 3Õ 3ç CÑ Cå *ô	˜G¡TÐ*=Ó%>ô 	ôpØÐ	Ð(=ópr   