Ë
    :vžjX  ã                  ó*  — d Z ddlmZ ddlZddlZddlZddlZddlZddl	Z	ddl
mZ ddlmZ ddlZddlmZmZmZmZmZmZmZmZ ddlmZ ddlm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%m&Z&  G d„ de'«      Z(dd„Z) G d„ de«      Z* G d„ de*«      Z+y)z%A kernel manager for multiple kernelsé    )ÚannotationsN©Úwraps)ÚPath)ÚAnyÚBoolÚDictÚDottedObjectNameÚInstanceÚUnicodeÚdefaultÚobserve)ÚLoggingConfigurable)Úimport_itemé   )ÚKernelConnectionInfo)ÚNATIVE_KERNEL_NAMEÚKernelSpecManager)ÚKernelManager)Úensure_asyncÚrun_syncÚutcnowc                  ó   — e Zd Zy)ÚDuplicateKernelErrorN)Ú__name__Ú
__module__Ú__qualname__© ó    úr/workspace/moltex-experiments/.pixi/envs/default/lib/python3.12/site-packages/jupyter_client/multikernelmanager.pyr   r      s   „ Ør   r   c                óD   ‡ — t        ‰ «      	 	 	 	 	 	 	 	 	 	 dˆ fd„«       }|S )zDdecorator for proxying MKM.method(kernel_id) to individual KMs by IDc                ó€   •— | j                  |«      }t        |‰j                  «      } ||i |¤Ž} ‰| |g|¢­i |¤Ž |S ©N)Ú
get_kernelÚgetattrr   )ÚselfÚ	kernel_idÚargsÚkwargsÚkmÚmethodÚrÚfs          €r    Úwrappedzkernel_method.<locals>.wrapped"   sM   ø€ ð
 �_‰_˜YÓ'ˆÜ˜˜QŸZ™ZÓ(ˆá�DÐ#˜FÑ#ˆñ 	
ˆ$�	Ð+˜DÒ+ FÒ+àˆr   )
r&   út.Anyr'   Ústrr(   r/   r)   r/   Úreturnzt.Callable | t.Awaitabler   )r-   r.   s   ` r    Úkernel_methodr2      sJ   ø€ ô ˆ1ƒXðØðØ #ðØ,1ðØ=Bðà	!ôó ðð €Nr   c                  ó@  ‡ — e Zd ZdZ eed¬«      j                  d¬«      Z ee	d¬«      Z
 edd¬«      j                  d¬«      Z ed	«      d8d
„«       Z ed¬«      Z ed«      d9d„«       Zd9d„Z edd¬«      j                  d¬«      Z ed«      Z ed«      Z e«       Zed:d„«       Z ed«      d;d„«       Z ed«      Z edd¬«      Z e«       Zd<ˆ fd„Z d=ˆ fd„Z!d>d„Z"d?d„Z#d@d„Z$	 	 	 	 	 	 dAd„Z%dBd„Z&	 	 	 	 	 	 	 	 dCd„Z'	 	 	 	 	 	 dDd„Z(dEd „Z)dd!œdFd"„Z* e+e*«      Z,	 	 dG	 	 	 	 	 	 	 dHd#„Z- e+e-«      Z.e/dIdJd$„«       Z0e/	 	 dK	 	 	 	 	 	 	 dLd%„«       Z1e/dIdMd&„«       Z2dNd'„Z3dIdOd(„Z4 e+e4«      Z5dPd)„Z6e/dQd*„«       Z7dIdRd+„Z8 e+e8«      Z9e/d@d,„«       Z:dPd-„Z;dNd.„Z<e/	 dS	 	 	 	 	 	 	 dTd/„«       Z=e/	 dS	 	 	 	 	 	 	 dTd0„«       Z>e/dUd1„«       Z?e/	 dV	 	 	 	 	 dWd2„«       Z@e/	 dV	 	 	 	 	 dWd3„«       ZAe/	 dV	 	 	 	 	 dWd4„«       ZBe/	 dV	 	 	 	 	 dWd5„«       ZCe/	 dV	 	 	 	 	 dWd6„«       ZDdXd7„ZEˆ xZFS )YÚMultiKernelManagerz&A class for managing multiple kernels.z'The name of the default kernel to start©ÚhelpT©Úconfig)Ú
allow_nonez)jupyter_client.ioloop.IOLoopKernelManagerzƒThe kernel manager class.  This is configurable to allow
        subclassing of the KernelManager for customized behavior.
        Úkernel_manager_classc                ó.   — | j                  «       | _        y r#   )Ú_create_kernel_manager_factoryÚkernel_manager_factory)r&   Úchanges     r    Ú_kernel_manager_class_changedz0MultiKernelManager._kernel_manager_class_changedD   s   € à&*×&IÑ&IÓ&KˆÕ#r   z)this is kernel_manager_class after importr=   c                ó"   — | j                  «       S r#   )r<   ©r&   s    r    Ú_kernel_manager_factory_defaultz2MultiKernelManager._kernel_manager_factory_defaultJ   s   € à×2Ñ2Ó4Ð4r   c                óB   ‡ ‡— t        ‰ j                  «      Šdˆˆ fd„}|S )Nc                 ó¾   •— ‰j                   rG‰j                  j                  r‰j                  «       ‰_        |j	                  d‰j                  «        ‰| i |¤Ž}|S )NÚcontext)Úshared_contextrE   ÚclosedÚ_context_defaultÚ
setdefault)r(   r)   r*   Úkernel_manager_ctorr&   s      €€r    Úcreate_kernel_managerzPMultiKernelManager._create_kernel_manager_factory.<locals>.create_kernel_managerQ   sQ   ø€ Ø×"Ò"Ø—<‘<×&Ò&à#'×#8Ñ#8Ó#:�D”LØ×!Ñ! )¨T¯\©\Ô:Ù$ dÐ5¨fÑ5ˆBØˆIr   )r(   r/   r)   r/   r1   r   )r   r:   )r&   rK   rJ   s   ` @r    r<   z1MultiKernelManager._create_kernel_manager_factoryN   s!   ù€ Ü)¨$×*CÑ*CÓDÐö	ð %Ð$r   z4Share a single zmq.Context to talk to all my kernelsúzmq.ContextFc                ó   — | j                   S )z#A shim for backwards compatibility.)Ú_pending_kernelsrA   s    r    Ú_starting_kernelsz$MultiKernelManager._starting_kernelsg   s   € ð ×$Ñ$Ð$r   rE   c                ó8   — d| _         t        j                  «       S ©NT)Ú_created_contextÚzmqÚContextrA   s    r    rH   z#MultiKernelManager._context_defaultl   s   € à $ˆÔÜ�{‰{‹}Ðr   Ú Nc                ó2   •— t        ‰| �  |i |¤Ž i | _        y r#   )ÚsuperÚ__init__Úkernel_id_to_connection_file)r&   r(   r)   Ú	__class__s      €r    rX   zMultiKernelManager.__init__v   s   ø€ Ü‰Ñ˜$Ð) &Ò)Ø=?ˆÕ)r   c                ó,  •— | j                   rf| j                  rZ| j                  j                  sD| j                  r| j                  j	                  d| «       | j                  j                  d¬«       	 t        ‰| �  } |«        y# t        $ r Y yw xY w)z:Handle garbage collection.  Destroy context if applicable.zDestroying zmq context for %siè  )ÚlingerN)	rR   rE   rG   ÚlogÚdebugÚdestroyrW   Ú__del__ÚAttributeError)r&   Ú	super_delrZ   s     €r    r`   zMultiKernelManager.__del__z   sv   ø€ à× Ò  T§\¢\¸$¿,¹,×:MÒ:MØ�xŠxØ—‘—‘Ð>ÀÔEØ�L‰L× Ñ ¨Ð Ô-ð	Ü™™ˆIñ �Køô ò 	Ùð	ús   Á5
B Â	BÂBc                ó   — | j                   ��
t        | j                   «      }|j                  «       �rä|j                  «       D �cg c]  }|j	                  «       sŒ|‘Œ }}t        | j                  j                  «       «      }t        | j                  j                  «       «      }t        | j                  j                  «       «      D ]5  }||vsŒ||j                  |«         }| j                  |= | j                  |= Œ7 |D �]  }|| j                  j                  «       v rŒ!	 t        j                  |j                  «       «      }| j                  j!                  d|«       d|v rd|v sŒj| j#                  «       }|| j                  |<   | j%                  | | j                  d¬«      }	|	j'                  |«       t)        «       |	_        d|	_        d|	_        ||	_        |d   |	_        |	j4                  j7                  d«       |	| j                  |<   �Œ t        | j                  j                  «       «      S c c}w # t        $ r Y �ŒGw xY w)	z6Return a list of the kernel ids of the active kernels.NzLoading connection file %sÚkernel_nameÚkeyF)Úparentr]   Úowns_kernelÚidler   )Úexternal_connection_dirr   Úis_dirÚiterdirÚis_fileÚlistrY   ÚkeysÚvaluesÚindexÚ_kernelsÚjsonÚloadsÚ	read_textÚ	Exceptionr]   r^   Únew_kernel_idr=   Úload_connection_infor   Úlast_activityÚexecution_stateÚconnectionsr'   rd   ÚreadyÚ
set_result)
r&   ri   ÚpÚconnection_filesÚkÚvÚconnection_filer'   Úconnection_infor*   s
             r    Úlist_kernel_idsz"MultiKernelManager.list_kernel_ids‡   s  € à×'Ñ'Ñ3Ü&*¨4×+GÑ+GÓ&HÐ#Ø&×-Ñ-Õ/Ø/F×/NÑ/NÔ/PÓ#`Ñ/P¨!ÐTU×T]ÑT]ÕT_¢AÐ/PÐ Ð#`ô ˜×:Ñ:×?Ñ?ÓAÓB�Ü˜×:Ñ:×AÑAÓCÓD�Ü'+¨D×,MÑ,M×,TÑ,TÓ,VÖ'W�OØ&Ð.>Ò>Ø$% a§g¡g¨oÓ&>Ñ$?˜	Ø ×=Ñ=¸iÐHØ ŸM™M¨)Ñ4ð	 (Xô (8�OØ&¨$×*KÑ*K×*RÑ*RÓ*TÑTØ ð!Ü@DÇ
Á
Ø+×5Ñ5Ó7óA˜ð
 —H‘H—N‘NÐ#?ÀÔQØ)¨_Ñ<ÀÈ/ÑAYØ à $× 2Ñ 2Ó 4�IØCR�D×5Ñ5°iÑ@Ø×4Ñ4Ø#Ø ŸH™HØ$)ð 5ó �Bð
 ×+Ñ+¨OÔ<Ü'-£x�BÔ$Ø)/�BÔ&Ø%&�B”NØ#,�B”LØ%4°]Ñ%C�B”NØ—H‘H×'Ñ'¨Ô-à/1�D—M‘M )Ó,ð9 (8ô@ �D—M‘M×&Ñ&Ó(Ó)Ð)ùòY $aøô& %ò !Ú ð!ús   ÁH;ÁH;Ä'#I É 	IÉIc                ó4   — t        | j                  «       «      S )z%Return the number of running kernels.)Úlenrƒ   rA   s    r    Ú__len__zMultiKernelManager.__len__º   s   € ä�4×'Ñ'Ó)Ó*Ð*r   c                ó   — || j                   v S r#   )rq   ©r&   r'   s     r    Ú__contains__zMultiKernelManager.__contains__¾   s   € Ø˜DŸM™MÐ)Ð)r   c                ób  — |j                  d | j                  di |¤Ž«      }|| v rt        d|z  «      ‚|€| j                  }i }| j                  r| j                  |d<    | j
                  dt        j                  j                  | j                  d|z  «      | | j                  |dœ|¤Ž}|||fS )Nr'   zKernel already exists: %sÚkernel_spec_managerzkernel-%s.json)r�   rf   r]   rd   r   )Úpoprv   r   Údefault_kernel_namer‹   r=   ÚosÚpathÚjoinÚconnection_dirr]   )r&   rd   r)   r'   Úconstructor_kwargsr*   s         r    Úpre_start_kernelz#MultiKernelManager.pre_start_kernelÁ   sÎ   € ð —J‘J˜{Ð,>¨D×,>Ñ,>Ñ,HÀÑ,HÓIˆ	Ø˜ÑÜ&Ð'BÀYÑ'NÓOÐOàÐØ×2Ñ2ˆKð  ÐØ×#Ò#Ø8<×8PÑ8PÐÐ4Ñ5Ø(ˆT×(Ñ(ð 
ÜŸG™GŸL™L¨×)<Ñ)<Ð>NÐQZÑ>ZÓ[ØØ—‘Ø#ñ	
ð
 !ñ
ˆð �; 	Ð)Ð)r   c               óL   — || v r | j                   |   j                  |¬«       yy)zª
        Allow to update the environment of the given kernel.

        Forward the update env request to the corresponding kernel.

        .. version-added: 8.5
        )ÚenvN)rq   Ú
update_env)r&   r'   r•   s      r    r–   zMultiKernelManager.update_envÚ   s+   € ð ˜ÑØ�M‰M˜)Ñ$×/Ñ/°CÐ/Õ8ð r   c              ƒ  óÞ   K  — 	 |ƒ d {  –—†  || j                   |<   | j                  j                  |d «       y 7 Œ0# t        $ r%}| j                  j                  |«       Y d }~y d }~ww xY w­wr#   )rq   rN   rŒ   ru   r]   Ú	exception)r&   r'   r*   Úkernel_awaitableÚes        r    Ú_add_kernel_when_readyz)MultiKernelManager._add_kernel_when_readyå   sc   è ø€ ð	"Ø"×"Ð"Ø')ˆD�M‰M˜)Ñ$Ø×!Ñ!×%Ñ% i°Õ6ð #ùô ò 	"Ø�H‰H×Ñ˜q×!Ñ!ûð	"üs7   ‚A-„< ‰:Š/< ¹A-º< ¼	A*ÁA%Á A-Á%A*Á*A-c              ƒ  óâ   K  — 	 |ƒ d {  –—†  | j                  |«       | j                  j                  |d «       y 7 Œ2# t        $ r%}| j                  j                  |«       Y d }~y d }~ww xY w­wr#   )Úremove_kernelrN   rŒ   ru   r]   r˜   )r&   r'   r™   rš   s       r    Ú_remove_kernel_when_readyz,MultiKernelManager._remove_kernel_when_readyï   sc   è ø€ ð	"Ø"×"Ð"Ø×Ñ˜yÔ)Ø×!Ñ!×%Ñ% i°Õ6ð #ùô ò 	"Ø�H‰H×Ñ˜q×!Ñ!ûð	"üs7   ‚A/„> ‰<Š1> »A/¼> ¾	A,ÁA'Á"A/Á'A,Á,A/c                ó   — t        | dd«      S )zReturns a boolean; a clearer method for determining if
        this multikernelmanager is using pending kernels or not
        Úuse_pending_kernelsF)r%   rA   s    r    Ú_using_pending_kernelsz)MultiKernelManager._using_pending_kernelsù   s   € ô �tÐ2°EÓ:Ð:r   )rd   c             ‹  ó,  K  — | j                  ||«      \  }}}t        |t        «      s3| j                  j	                  d| j
                  j                  › d�«       ||d<   t         |j                  di |¤Ž«      }t        j                  | j                  |||«      «      }|| j                  |<   | j                  «       r|| j                  |<   |S |ƒ d{  –—†  |j                  j!                  «       r|j                  j!                  «       ‚|S 7 Œ:­w)zéStart a new kernel.

        The caller can pick a kernel_id by passing one in as a keyword arg,
        otherwise one will be generated using new_kernel_id().

        The kernel ID for the newly started kernel is returned.
        zKernel manager class (z() is not an instance of 'KernelManager'!r'   Nr   )r“   Ú
isinstancer   r]   Úwarningr:   rZ   r   Ústart_kernelÚasyncioÚcreate_taskr›   rN   r¡   rq   r{   r˜   )r&   rd   r)   r*   r'   ÚstarterÚtasks          r    Ú_async_start_kernelz&MultiKernelManager._async_start_kernelÿ   s  è ø€ ð &*×%:Ñ%:¸;ÈÓ%OÑ"ˆˆK˜Ü˜"œmÔ,Ø�H‰H×ÑØ(¨×)BÑ)B×)LÑ)LÐ(MÐMuÐvôð (ˆˆ{Ñä˜˜rŸ™Ñ8°Ñ8Ó9ˆÜ×"Ñ" 4×#>Ñ#>¸yÈ"ÈgÓ#VÓWˆØ+/ˆ×Ñ˜iÑ(à×&Ñ&Ô(ð (*ˆD�M‰M˜)Ñ$ð Ðð �JˆJà�x‰x×!Ñ!Ô#Ø—h‘h×(Ñ(Ó*Ð*àÐð ús   ‚CDÃDÃ;Dc              ƒ  ó„  K  — | j                   j                  d|«       || j                  v ra| j                  |   }	 |ƒ d{  –—†  | j                  |«      }t	        j
                  t        j                  |j                  «      ƒ d{  –—†  | j                  |«      }|j                  j                  «       s,|j                  j                  «       r| j                  |«       yt        |j                  ||«      «      }t        j                   | j#                  ||«      «      }|| j                  |<   | j%                  «       s?|ƒ d{  –—†  |j                  j                  «       r|j                  j                  «       ‚yy7 �ŒB7 Œý# t        j                  $ r Y �Œt        $ r | j                  |«       Y yw xY w7 Œt­w)a3  Shutdown a kernel by its kernel uuid.

        Parameters
        ==========
        kernel_id : uuid
            The id of the kernel to shutdown.
        now : bool
            Should the kernel be shutdown forcibly using a signal.
        restart : bool
            Will the kernel be restarted?
        úKernel shutdown: %sN)r]   ÚinforN   r$   ÚtÚcastr¦   ÚFuturer{   ÚCancelledErrorru   r�   Ú	cancelledr˜   r   Úshutdown_kernelÚensure_futurerž   r¡   )r&   r'   ÚnowÚrestartr©   r*   ÚstopperÚfuts           r    Ú_async_shutdown_kernelz)MultiKernelManager._async_shutdown_kernel   sr  è ø€ ð" 	�‰�‰Ð+¨YÔ7à˜×-Ñ-Ñ-Ø×(Ñ(¨Ñ3ˆDðØ—
�
Ø—_‘_ YÓ/�Ü—f‘fœWŸ^™^¨R¯X©XÓ6×6Ð6ð �_‰_˜YÓ'ˆà�x‰x×!Ñ!Ô#¨¯©×(:Ñ(:Ô(<Ø×Ñ˜yÔ)ØÜ˜r×1Ñ1°#°wÓ?Ó@ˆÜ×#Ñ# D×$BÑ$BÀ9ÈgÓ$VÓWˆØ+.ˆ×Ñ˜iÑ(à×*Ñ*Ô,Ø�IˆIà�x‰x×!Ñ!Ô#Ø—h‘h×(Ñ(Ó*Ð*ð $ð -ð# ùà6ùÜ×)Ñ)ò ÚÜò Ø×"Ñ" 9Ô-Ùðúð úsf   ‚:G ½F	 ÁFÁAF	 Â	FÂ
F	 ÂB;G Å	F>Å
:G ÆF	 ÆF	 Æ	F;ÆG ÆF;Æ8G Æ:F;Æ;G c                 ó   — y)z,Ask a kernel to shut down by its kernel uuidNr   ©r&   r'   r¶   s      r    Úrequest_shutdownz#MultiKernelManager.request_shutdownO  ó   � r   c                ó<   — | j                   j                  d|«       y)zDWait for a kernel to finish shutting down, and kill it if it doesn'tr¬   N©r]   r­   )r&   r'   ÚwaittimeÚpollintervals       r    Úfinish_shutdownz"MultiKernelManager.finish_shutdownS  s   € ð 	�‰�‰Ð+¨YÕ7r   c                 ó   — y)zClean up a kernel's resourcesNr   r»   s      r    Úcleanup_resourcesz$MultiKernelManager.cleanup_resources]  r½   r   c                ó:   — | j                   j                  |d«      S )záremove a kernel from our mapping.

        Mainly so that a kernel can be removed if it is already dead,
        without having to call shutdown_kernel.

        The kernel object is returned, or `None` if not found.
        N)rq   rŒ   rˆ   s     r    r�   z MultiKernelManager.remove_kernela  s   € ð �}‰}× Ñ  ¨DÓ1Ð1r   c              ƒ  ó(  K  — | j                  «       }|t        | j                  «      z  }t        | j                  j	                  «       «      }t        |«      D �cg c]  }| j                  ||¬«      ‘Œ }}t        j                  |Ž ƒ d{  –—†  | j                  «       r|D ]  }	 |j                  ƒ d{  –—†  Œ yyc c}w 7 Œ77 Œ# t        j                  $ r* | j                  |j                     j                  «        Y Œat        $ r Y Œkw xY w­w)zShutdown all kernels.©rµ   N)rƒ   rm   rN   rq   ro   Úsetr¹   r¦   Úgatherr¡   r{   r±   r'   Úcancelru   )r&   rµ   ÚkidsÚkmsÚkidÚfutsr*   s          r    Ú_async_shutdown_allz&MultiKernelManager._async_shutdown_allk  sï   è ø€ à×#Ñ#Ó%ˆØ”�T×*Ñ*Ó+Ñ+ˆÜ�4—=‘=×'Ñ'Ó)Ó*ˆÜEHÈÄYÓOÁY¸c�×+Ñ+¨C°SÐ+Õ9ÀYˆÐOÜ�n‰n˜dÐ#×#Ð#à×&Ñ&Ô(Û�ðØŸ(™(—N‘Nñ ð )ùò PØ#øð
 #ùÜ×-Ñ-ò AØ×)Ñ)¨"¯,©,Ñ7×>Ñ>Ö@Ü ò áðüs`   ‚ADÁB?Á5DÂCÂDÂ'CÂ6CÂ7CÂ;
DÃCÃ:DÄDÄDÄDÄDÄDc                óÎ   — | j                  |«      }|j                  j                  «       sd}t        |«      ‚|j	                  «       }| j
                  j                  d|«       |S )z¢Interrupt (SIGINT) the kernel by its uuid.

        Parameters
        ==========
        kernel_id : uuid
            The id of the kernel to interrupt.
        z/Kernel is in a pending state. Cannot interrupt.zKernel interrupted: %s)r$   r{   ÚdoneÚRuntimeErrorÚinterrupt_kernelr]   r­   )r&   r'   ÚkernelÚmsgÚouts        r    rÓ   z#MultiKernelManager.interrupt_kernel  sX   € ð —‘ Ó+ˆØ�|‰|× Ñ Ô"ØCˆCÜ˜sÓ#Ð#Ø×%Ñ%Ó'ˆØ�‰�‰Ð.°	Ô:Øˆ
r   c                ó>   — | j                   j                  d||«       y)aR  Sends a signal to the kernel by its uuid.

        Note that since only SIGTERM is supported on Windows, this function
        is only useful on Unix systems.

        Parameters
        ==========
        kernel_id : uuid
            The id of the kernel to signal.
        signum : int
            Signal number to send kernel.
        zSignaled Kernel %s with %sNr¿   )r&   r'   Úsignums      r    Úsignal_kernelz MultiKernelManager.signal_kernel�  s   € ð 	�‰�‰Ð2°I¸vÕFr   c              ƒ  ó  K  — | j                  |«      }| j                  «       r'|j                  j                  «       sd}t	        |«      ‚t        |j                  |¬«      «      ƒ d{  –—†  | j                  j                  d|«       y7 Œ!­w)aE  Restart a kernel by its uuid, keeping the same ports.

        Parameters
        ==========
        kernel_id : uuid
            The id of the kernel to interrupt.
        now : bool, optional
            If True, the kernel is forcefully restarted *immediately*, without
            having a chance to do any cleanup action.  Otherwise the kernel is
            given 1s to clean up before a forceful restart is issued.

            In all cases the kernel is restarted, the only difference is whether
            it is given a chance to perform a clean shutdown or not.
        z-Kernel is in a pending state. Cannot restart.rÇ   NzKernel restarted: %s)	r$   r¡   r{   rÑ   rÒ   r   Úrestart_kernelr]   r­   )r&   r'   rµ   rÔ   rÕ   s        r    Ú_async_restart_kernelz(MultiKernelManager._async_restart_kernelŸ  su   è ø€ ð —‘ Ó+ˆØ×&Ñ&Ô(°·±×1BÑ1BÔ1DØAˆCÜ˜sÓ#Ð#Ü˜6×0Ñ0°SÐ0Ó9Ó:×:Ð:Ø�‰�‰Ð,¨iÕ8ð 	;ús   ‚A'BÁ)BÁ*"Bc                 ó   — y)zìIs the kernel alive.

        This calls KernelManager.is_alive() which calls Popen.poll on the
        actual kernel subprocess.

        Parameters
        ==========
        kernel_id : uuid
            The id of the kernel.
        Nr   rˆ   s     r    Úis_alivezMultiKernelManager.is_alive·  r½   r   c                ó(   — || vrt        d|z  «      ‚y)zcheck that a kernel id is validzKernel with id not found: %sN)ÚKeyErrorrˆ   s     r    Ú_check_kernel_idz#MultiKernelManager._check_kernel_idÄ  s    € à˜DÑ ÜÐ9¸IÑEÓFÐFð !r   c                óB   — | j                  |«       | j                  |   S )z¨Get the single KernelManager object for a kernel by its uuid.

        Parameters
        ==========
        kernel_id : uuid
            The id of the kernel.
        )rá   rq   rˆ   s     r    r$   zMultiKernelManager.get_kernelÉ  s!   € ð 	×Ñ˜iÔ(Ø�}‰}˜YÑ'Ð'r   c                 ó   — y)z&add a callback for the KernelRestarterNr   ©r&   r'   ÚcallbackÚevents       r    Úadd_restart_callbackz'MultiKernelManager.add_restart_callbackÔ  r½   r   c                 ó   — y)z)remove a callback for the KernelRestarterNr   rä   s       r    Úremove_restart_callbackz*MultiKernelManager.remove_restart_callbackÚ  r½   r   c                 ó   — y)aË  Return a dictionary of connection data for a kernel.

        Parameters
        ==========
        kernel_id : uuid
            The id of the kernel.

        Returns
        =======
        connection_dict : dict
            A dict of the information needed to connect to a kernel.
            This includes the ip address and the integer port
            numbers of the different channels (stdin_port, iopub_port,
            shell_port, hb_port).
        Nr   rˆ   s     r    Úget_connection_infoz&MultiKernelManager.get_connection_infoà  r½   r   c                 ó   — y)a6  Return a zmq Socket connected to the iopub channel.

        Parameters
        ==========
        kernel_id : uuid
            The id of the kernel
        identity : bytes (optional)
            The zmq identity of the socket

        Returns
        =======
        stream : zmq Socket or ZMQStream
        Nr   ©r&   r'   Úidentitys      r    Úconnect_iopubz MultiKernelManager.connect_iopubò  r½   r   c                 ó   — y)a6  Return a zmq Socket connected to the shell channel.

        Parameters
        ==========
        kernel_id : uuid
            The id of the kernel
        identity : bytes (optional)
            The zmq identity of the socket

        Returns
        =======
        stream : zmq Socket or ZMQStream
        Nr   rí   s      r    Úconnect_shellz MultiKernelManager.connect_shell  r½   r   c                 ó   — y)a8  Return a zmq Socket connected to the control channel.

        Parameters
        ==========
        kernel_id : uuid
            The id of the kernel
        identity : bytes (optional)
            The zmq identity of the socket

        Returns
        =======
        stream : zmq Socket or ZMQStream
        Nr   rí   s      r    Úconnect_controlz"MultiKernelManager.connect_control  r½   r   c                 ó   — y)a6  Return a zmq Socket connected to the stdin channel.

        Parameters
        ==========
        kernel_id : uuid
            The id of the kernel
        identity : bytes (optional)
            The zmq identity of the socket

        Returns
        =======
        stream : zmq Socket or ZMQStream
        Nr   rí   s      r    Úconnect_stdinz MultiKernelManager.connect_stdin(  r½   r   c                 ó   — y)a3  Return a zmq Socket connected to the hb channel.

        Parameters
        ==========
        kernel_id : uuid
            The id of the kernel
        identity : bytes (optional)
            The zmq identity of the socket

        Returns
        =======
        stream : zmq Socket or ZMQStream
        Nr   rí   s      r    Ú
connect_hbzMultiKernelManager.connect_hb:  r½   r   c                ó<   — t        t        j                  «       «      S )zé
        Returns the id to associate with the kernel for this request. Subclasses may override
        this method to substitute other sources of kernel ids.
        :param kwargs:
        :return: string-ized version 4 uuid
        )r0   ÚuuidÚuuid4)r&   r)   s     r    rv   z MultiKernelManager.new_kernel_idL  s   € ô ”4—:‘:“<Ó Ð r   )r>   r/   r1   ÚNone)r1   ú
t.Callable)r1   Údict)r1   rL   )r(   r/   r)   r/   r1   rû   )r1   rû   )r1   z	list[str])r1   Úint)r'   r0   r1   Úbool)rd   ú
str | Noner)   r/   r1   ztuple[KernelManager, str, str])r'   r0   r•   zt.Dict[str, str]r1   rû   )r'   r0   r*   r   r™   út.Awaitabler1   rû   )r'   r0   r™   r  r1   rû   )r1   rÿ   )rd   r   r)   r/   r1   r0   )FF)r'   r0   rµ   úbool | Noner¶   r  r1   rû   )F)r'   r0   r¶   r  r1   rû   )Ngš™™™™™¹?)r'   r0   rÀ   úfloat | NonerÁ   r  r1   rû   )r'   r0   r¶   rÿ   r1   rû   )r'   r0   r1   r   )rµ   rÿ   r1   rû   )r'   r0   r1   rû   )r'   r0   rØ   rþ   r1   rû   )r'   r0   rµ   rÿ   r1   rû   )r¶   )r'   r0   rå   rü   ræ   r0   r1   rû   )r'   r0   r1   zdict[str, t.Any]r#   )r'   r0   rî   zbytes | Noner1   zsocket.socket)r)   r/   r1   r0   )Gr   r   r   Ú__doc__r   r   Útagr�   r   r   r‹   r
   r:   r   r?   r   r=   r   rB   r<   r   rF   rE   rR   r	   rN   ÚpropertyrO   rH   r‘   ri   rq   rX   r`   rƒ   r†   r‰   r“   r–   r›   rž   r¡   rª   r   r¥   r¹   r³   r2   r¼   rÂ   rÄ   r�   rÏ   Úshutdown_allrÓ   rÙ   rÜ   rÛ   rÞ   rá   r$   rç   ré   rë   rï   rñ   ró   rõ   r÷   rv   Ú__classcell__)rZ   s   @r    r4   r4   4   sC  ø„ Ù0á!ØÐ!Jôç	�c�€cÓð ñ #Ð#4ÀÔFÐá+Ø3ðô÷
 
�c�€cÓð ñ Ð#Ó$òLó %ðLñ !Ð&QÔRÐáÐ%Ó&ò5ó 'ð5ó%ñ ØØCô÷ 
�c�€cÓð ñ
 �}Ó%€Gá˜E“{Ðá“vÐàò%ó ð%ñ ˆYÓòó ðñ ˜R“[€NÙ% d°tÔ<Ðá‹v€Hõ@õó1*óf+ó*ð*Ø%ð*Ø/4ð*à	'ó*ó2	9ð"Øð"Ø"/ð"ØCNð"à	ó"ð"Øð"Ø0;ð"à	ó"ó;ð FJõ ñ> Ð/Ó0€Lð
 !Ø$ð	++àð++ð ð++ð ð	++ð
 
ó++ñZ Ð5Ó6€Oàó;ó ð;ð ð "&Ø%(ð	8àð8ð ð8ð #ð	8ð
 
ò8ó ð8ð ó,ó ð,ó2ôñ$ Ð/Ó0€Lóð  òGó ðGô9ñ, Ð3Ó4€Nàò
ó ð
óGó
	(ð àAJð5Øð5Ø(2ð5Ø;>ð5à	ò5ó ð5ð
 àAJð8Øð8Ø(2ð8Ø;>ð8à	ò8ó ð8ð
 òó ðð" à7;ðØðØ(4ðà	òó ðð" à7;ðØðØ(4ðà	òó ðð" à7;ðØðØ(4ðà	òó ðð" à7;ðØðØ(4ðà	òó ðð" à7;ðØðØ(4ðà	òó ð÷"!r   r4   c                  ó  — e Zd ZU  eddd¬«      Z edd¬«      j                  d¬«      Z ed	«      Z	 e
d
«      dd„«       Zej                  Zded<   ej                   Zded<   ej$                  Zded<   ej(                  Zded<   y)ÚAsyncMultiKernelManagerz.jupyter_client.ioloop.AsyncIOLoopKernelManagerTzˆThe kernel manager class.  This is configurable to allow
        subclassing of the AsyncKernelManager for customized behavior.
        )r8   r6   Fz’Whether to make kernels available before the process has started.  The
        kernel has a `.ready` future which can be awaited before connectingr5   r7   úzmq.asyncio.ContextrE   c                óL   — d| _         t        j                  j                  «       S rQ   )rR   rS   r¦   rT   rA   s    r    rH   z(AsyncMultiKernelManager._context_defaultg  s   € à $ˆÔÜ�{‰{×"Ñ"Ó$Ð$r   zt.Callable[..., t.Awaitable]r¥   rÛ   r³   r  N)r1   r  )r   r   r   r
   r:   r   r  r    r   rE   r   rH   r4   rª   r¥   Ú__annotations__rÜ   rÛ   r¹   r³   rÏ   r  r   r   r    r
  r
  V  s©   … Ù+Ø8ØðôÐñ ØðOô÷ 
�c�€cÓð	 ñ Ð,Ó-€GáˆYÓò%ó ð%ð 2D×1WÑ1W€LÐ.ÓWØ3E×3[Ñ3[€NÐ0Ó[Ø4F×4]Ñ4]€OÐ1Ó]Ø1C×1WÑ1W€LÐ.ÔWr   r
  )r-   rü   r1   rü   ),r  Ú
__future__r   r¦   rr   rŽ   ÚsocketÚtypingr®   rù   Ú	functoolsr   Úpathlibr   rS   Ú	traitletsr   r   r	   r
   r   r   r   r   Útraitlets.config.configurabler   Útraitlets.utils.importstringr   Úconnectr   Ú
kernelspecr   r   Úmanagerr   Úutilsr   r   r   ru   r   r2   r4   r
  r   r   r    Ú<module>r     sv   ðÙ +õ #ã Û Û 	Û Û Û Ý Ý ã 
ß \× \Ó \Ý =Ý 4å )ß =Ý "ß 1Ñ 1ô	˜9ô 	óô*_!Ð,ô _!ôDXÐ0õ Xr   