Ë
    :vžjC  ã                   óh   — d Z ddlZddlZddlmZ ddlmZ ddlmZ  G d„ de«      Z	 G d	„ d
e	«      Z
y)zœA basic in process kernel monitor with autorestarting.

This watches a kernel's state using KernelManager.is_alive and auto
restarts the kernel if it dies.
é    N)ÚAny)ÚInstanceé   )ÚKernelRestarterc                   ó@   — e Zd ZdZ ed«      Zdefd„ZdZdd„Z	dd„Z
y)	ÚIOLoopKernelRestarterz!Monitor and autorestart a kernel.ztornado.ioloop.IOLoopÚreturnc                 óz   — t        j                  dt        d¬«       ddlm} |j
                  j                  «       S )Nz>IOLoopKernelRestarter.loop is deprecated in jupyter-client 5.2é   )Ú
stacklevelr   )Úioloop)ÚwarningsÚwarnÚDeprecationWarningÚtornador   ÚIOLoopÚcurrent)Úselfr   s     úp/workspace/moltex-experiments/.pixi/envs/default/lib/python3.12/site-packages/jupyter_client/ioloop/restarter.pyÚ_loop_defaultz#IOLoopKernelRestarter._loop_default   s/   € Ü�‰ØLÜØõ	
õ
 	#à�}‰}×$Ñ$Ó&Ð&ó    Nc                 ó¨   — | j                   €Fddlm}  || j                  d| j                  z  «      | _         | j                   j                  «        yy)z Start the polling of the kernel.Nr   )ÚPeriodicCallbackiè  )Ú
_pcallbackÚtornado.ioloopr   ÚpollÚtime_to_deadÚstart)r   r   s     r   r   zIOLoopKernelRestarter.start#   sG   € à�?‰?Ð"Ý7á.Ø—	‘	Ø�t×(Ñ(Ñ(óˆDŒOð �O‰O×!Ñ!Õ#ð #r   c                 ó`   — | j                   �"| j                   j                  «        d| _         yy)zStop the kernel polling.N)r   Ústop)r   s    r   r    zIOLoopKernelRestarter.stop.   s(   € à�?‰?Ð&Ø�O‰O× Ñ Ô"Ø"ˆD�Oð 'r   ©r	   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úloopr   r   r   r   r    © r   r   r   r      s-   „ Ù+áÐ+Ó,€Dð'˜só 'ð €Jó	$ô#r   r   c                   ó   — e Zd ZdZdd„Zy)ÚAsyncIOLoopKernelRestarterz"An async io loop kernel restarter.Nc              ƒ   óx  K  — | j                   r| j                  j                  d«       | j                  j                  «       ƒ d{  –—† }t	        j                  «       }|�s"|| _        | j                  r| xj                  dz  c_        nd| _        | j                  | j                  kD  rK| j                  j                  d«       | j                  d«       d| _        d| _        | j                  «        y| j                  xr | j                  }| j                  j                  d| j                  | j                  |rd	nd
«       | j                  d«       | j                  j                  d|¬«      ƒ d{  –—†  d| _        y| j                   }| j                  j"                  r&| j                  j"                  j%                  |¬«      }| j                  r|| j
                  z
  |k\  rd| _        | j                  r6|| j
                  z
  |k\  r#| j                  j                  d«       d| _        yyy7 �Œî7 Œ¿­w)zPoll the kernel.zPolling kernel...Né   z*AsyncIOLoopKernelRestarter: restart failedÚdeadFr   zFAsyncIOLoopKernelRestarter: restarting kernel (%i/%i), %s random portsÚnewÚkeepÚrestartT)ÚnowÚnewports)Úrecommendedz8AsyncIOLoopKernelRestarter: restart apparently succeeded)ÚdebugÚlogÚkernel_managerÚis_aliveÚtimeÚ
_last_deadÚ_restartingÚ_restart_countÚrestart_limitÚwarningÚ_fire_callbacksr    Úrandom_ports_until_aliveÚ_initial_startupÚinfoÚrestart_kernelÚstable_start_timeÚprovisionerÚget_stable_start_time)r   r6   r0   r1   rB   s        r   r   zAsyncIOLoopKernelRestarter.poll8   sã  è ø€ à�:Š:Ø�H‰H�N‰NÐ.Ô/Ø×,Ñ,×5Ñ5Ó7×7ˆÜ�i‰i‹kˆÚØ!ˆDŒOØ×ÒØ×#Ò# qÑ(Ö#à&'�Ô#à×"Ñ" T×%7Ñ%7Ò7Ø—‘× Ñ Ð!MÔNØ×$Ñ$ VÔ,Ø#(�Ô Ø&'�Ô#Ø—	‘	•à×8Ñ8ÒR¸T×=RÑ=R�Ø—‘—‘Ø\Ø×'Ñ'Ø×&Ñ&Ù%‘E¨6ô	ð ×$Ñ$ YÔ/Ø×)Ñ)×8Ñ8¸TÈHÐ8ÓU×UÐUØ#'�Õ ð !%× 6Ñ 6ÐØ×"Ñ"×.Ò.Ø$(×$7Ñ$7×$CÑ$C×$YÑ$YØ 1ð %Zó %Ð!ð ×$Ò$¨¨t¯©Ñ)>ÐBSÒ)SØ(-�Ô%Ø×Ò C¨$¯/©/Ñ$9Ð=NÒ$NØ—‘—‘ÐYÔZØ#(�Õ ð %OÐðS 8ùð0 Vús&   ‚AH:ÁH5ÁD0H:Å8H8Å9B=H:È8H:r!   )r"   r#   r$   r%   r   r'   r   r   r)   r)   5   s
   „ Ù,ô/)r   r)   )r%   r7   r   Útypingr   Ú	traitletsr   Ú	restarterr   r   r)   r'   r   r   Ú<module>rH      s5   ðñó Û Ý å å 'ô #˜Oô  #ôF2)Ð!6õ 2)r   