
    0FieJ                    <   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Zd dl	Z	d dl
Z
d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZmZ  ej        d	          Z e
j        d
d
          Z e
j        d ed
                     e
j        dedd           e
j        dedd           e
j        dedd           e
j        dedd           e
j        dedd           e
j        dedd           e
j        dedd           e
j        ded d
d!"           e
j        d#d$d
d%d&'           e
j        d(d)d%d%d*'           e
j        d+d%d,-           e
j        d.edd/           e
j        d0e d%d
d1"           e
j        d2edd3           e
j        d4edd5           e
j        d6ed
d
d78           e
j!        d9d:e
j"        e;           e
j        d<ded=>           e
j#                    d?                                                                                                                                                                                                                                                 Z$e%d@k    r e$             dS dS )A    )annotationsN)	Scheduler)wait_for_signals)asyncio_run)get_loop_factory)validate_preload_argv)enable_proctitle_on_childrenenable_proctitle_on_currentzdistributed.schedulerT)existsresolve_path	scheduler)ignore_unknown_options)namecontext_settingsz--host z"URI, IP or hostname of this server)typedefaulthelpz--portzServing portz--interfacez0Preferred network interface like 'eth0' or 'ib0'z
--protocolzProtocol like tcp, tls, or ucxz--tls-ca-filez'CA cert(s) file for TLS (in PEM format)z
--tls-certz(certificate file for TLS (in PEM format)z	--tls-keyz(private key file for TLS (in PEM format)z--dashboard-addressz:8787z4Address on which to listen for diagnostics dashboard)r   r   show_defaultr   z--dashboard/--no-dashboard	dashboardFz+Launch the Dashboard [default: --dashboard])r   requiredr   z--jupyter/--no-jupyterjupyterzStart a Jupyter Server in the same process.  Warning: This will makeit possible for anyone with access to your dashboard address to runPython codez--show/--no-showzShow web UI [default: --show])r   r   z--dashboard-prefixzPrefix for the dashboard appz--use-xheadersz<User xheaders in dashboard app for ssl termination in headerz
--pid-filezFile to write the process PIDz--scheduler-filezFile to write connection information. This may be a good way to share connection information if your cluster is on a shared network file system.z	--preloadz[Module that should be loaded by the scheduler process  like "foo.bar" or "/path/to/foo.py".)r   multipleis_eagerr   preload_argv)nargsr   callbackz--idle-timeoutz4Time of inactivity after which to kill the scheduler)r   r   r   c           
     v    dt           j        d         v rt          j        dt          d           t          j                    \  }}}t          j        |dz  |dz  |dz             t                       t                       rdv r
                    d          rdv r
                    d          r3dv r d 
                    d          D             nt                    I rt          j        d
           s2t          t                    rdgdgt!                    dz
  z  z   ndt          t                    st          t                    rYt          t                    r5t          t                    r t!                    t!                    k    rt#          d          d d|	fd|
fd|ffD              s|	s|
s|rd rtt%          d          5 }|                    t)          t+          j                                         d	d	d	           n# 1 swxY w Y   fd}t/          j        |           t           j                            d          rQdd	l}|                    |j                  \  }}t=          ||dz            }|                    |j        ||f            f
d}	 tA           |            tC                                 tD          #                    d           d	S # tD          #                    d           w xY w)zLaunch a Dask scheduler.zdask-schedulerr   zbdask-scheduler is deprecated and will be removed in a future release; use `dask scheduler` instead   )
stacklevel   ,c                ,    g | ]}t          |          S  )int).0ps     >lib/python3.11/site-packages/distributed/cli/dask_scheduler.py
<listcomp>zmain.<locals>.<listcomp>   s    444qCFF444    Nz:\diR"  z8--protocol and --port must both be lists of equal lengthc                    i | ]
\  }}|||S Nr%   )r'   kvs      r)   
<dictcomp>zmain.<locals>.<dictcomp>   s/       Aq
 = 	
1 ==r+   tls_ca_filetls_scheduler_certtls_scheduler_keyztls://wc                 r    t           j                                       rt          j                    d S d S r-   )ospathr   remove)pid_files   r)   del_pid_filezmain.<locals>.del_pid_file   s9    w~~h'' $	(#####$ $r+   linux   c                   
K   t                               d           t          d
	d	t                               d           fd} fd}t          j         |                      }t          j         |                       }t          j        ||gt          j                   d {V \  }}d |D              t                               dj                   d S )	Nz/-----------------------------------------------)	securityhostportprotocol	interfacer   dashboard_addresshttp_prefixr   c                 P   K     d{V                                     d{V  dS )z/Wait for the scheduler to initialize and finishN)finished)r   s   r)   wait_for_scheduler_to_finishz7main.<locals>.run.<locals>.wait_for_scheduler_to_finish   sB      OOOOOOO$$&&&&&&&&&&&r+   c                 r   K   t                       d{V }                     d|             d{V  dS )zVWait for SIGINT or SIGTERM and close the scheduler upon receiving one of those signalsNzsignal-)reason)r   close)signumr   s    r)   wait_for_signals_and_closez5main.<locals>.run.<locals>.wait_for_signals_and_close   sY      +--------F//);6););/<<<<<<<<<<<r+   )return_whenc                6    g | ]}|                                 S r%   )result)r'   tasks     r)   r*   z%main.<locals>.run.<locals>.<listcomp>   s     (((4(((r+   zStopped scheduler at %rr%   )loggerinfor   asynciocreate_taskwaitFIRST_COMPLETEDaddress)rG   rL   wait_for_signals_and_close_task!wait_for_scheduler_to_finish_taskdone_r   r   rC   dashboard_prefixr?   rB   r   kwargsr@   rA   secs         @r)   runzmain.<locals>.run   s]     H 
/(
 
 
 
	 	H	' 	' 	' 	' 	'
	= 	= 	= 	= 	=
 +2*=&&((+
 +
' -4,?((**-
 -
)  ,.OP/
 
 
 
 
 
 
 
 
a
 	)(4((((-y/@AAAAAr+   )loop_factoryzEnd scheduler)$sysargvwarningswarnFutureWarninggcget_thresholdset_thresholdr
   r	   splitr&   research
isinstancelistlen
ValueErroropenwritestrr6   getpidatexitregisterplatform
startswithresource	getrlimitRLIMIT_NOFILEmax	setrlimitr   r   rQ   rR   )r?   r@   rA   rB   showr   r\   use_xheadersr9   r1   tls_certtls_keyrC   r   r]   g0g1g2fr:   rx   softhardlimitr_   r^   s   ```` `` `   ```          @r)   mainr      s   ^ 38A;&&p	
 	
 	
 	
 !##JBBR!VR!VR!V,,,!!! """ )SI%%OOC((	 'C8OO>>#&& $;;44DJJsOO444DDt99D|T|64)@)@|h%% 	6QC3x==1#455DDD(D!! YZd%;%; Y8T** 	Y*T42H2H 	YSN
 N
]]N N WXXX  K(!8, '*
  C  [ H   &(C   	&AGGC	$$%%%	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	&	$ 	$ 	$ 	$ 	$ 	%%%
|w'' B''(>??
dD$!)$$81E4=AAA(B (B (B (B (B (B (B (B (B (B (B (B (B (BT%CCEE(8(:(:;;;;O$$$$$O$$$$s   84H88H<?H<%L L8__main__)&
__future__r   rS   rt   rf   loggingr6   rj   ra   rc   clickdistributedr   distributed._signalsr   distributed.compatibilityr   distributed.configr   distributed.preloadingr   distributed.proctitler	   r
   	getLoggerrQ   Pathpem_file_option_typecommanddictoptionrr   boolargumentUNPROCESSEDversion_optionr   __name__r%   r+   r)   <module>r      s   " " " " " "   				  				 				 



   ! ! ! ! ! ! 1 1 1 1 1 1 1 1 1 1 1 1 / / / / / / 8 8 8 8 8 8       
 
	2	3	3 "uzDAAA  K$$d2S2S2STTThS"3WXXXhS$^DDD		;	   sD/O   		2	   		3	   		3	   		?    	6   
    %6UVVVsB5S   		G   lb7VWWW	
2	   	
+   "5#4?T   		?	   C% C%      XW   WV         ED YX UTxC%L zDFFFFF r+   