
    >ie)                    t    d dl mZ d dlZd dlZd dlZ	 d dlZn# e$ r dZY nw xY wdZd Zd Z	 e	            Z
dS )    )annotationsN)	cpu_count	CPU_COUNTc                 b   dD ]} 	 t          d| z            5 }t          |                                          }d d d            n# 1 swxY w Y   t          d| z            5 }t          |                                          }d d d            n# 1 swxY w Y   ||fc S # t          $ r Y w xY w	 t          d          5 }|                                                                                    d          d         }d d d            n# 1 swxY w Y   |                    d          s| d}t          d|z            5 }t          t          |                                                    d	                    \  }}||fcd d d            S # 1 swxY w Y   n# t          $ r Y nw xY wd
S )N)zcpuacct,cpuzcpu,cpuacctz"/sys/fs/cgroup/%s/cpu.cfs_quota_usz#/sys/fs/cgroup/%s/cpu.cfs_period_usz/proc/self/cgroup:/z/sys/fs/cgroup%scpu.max )NN)openintread	Exceptionstripsplitendswithmap)dirnamefquotaperiod
group_paths        +lib/python3.11/site-packages/dask/system.py_try_extract_cgroup_cpu_quotar      s    2  	:WDEE &AFFHH& & & & & & & & & & & & & & &;gEFF '!QVVXX' ' ' ' ' ' ' ' ' ' ' ' ' ' '&=    	 	 	D		%&& 	9!))//44R8J	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9""3'' 	*&)))J+j899 	!QQVVXX^^C%8%899ME6&=	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	!     :s   B""AB"A
	
B"A
	B"#"BB"B	B"B	B""
B/.B/3F A DF DF D/F AFF FF FF 
F,+F,c                    t          j                    } t          Z	 t          t          j                                                              }|dk    rt          | |          } n# t          $ r Y nw xY wt          j	        dk    rBt                      \  }}|/|-t          j        ||z            }|dk    rt          | |          } | S )zGet the available CPU count for this system.

    Takes the minimum value from the following locations:

    - Total system cpus available on the host.
    - CPU Affinity (if set)
    - Cgroups limit (if set)
    Nr   linux)osr   psutillenProcesscpu_affinityminr   sysplatformr   mathceil)countaffinity_countr   r   cgroups_counts        r   r   r   ,   s     LNNE 	 !1!1!>!>!@!@AAN!!E>22 	 	 	D	 |w577v!3 Iefn55Mq  E=11Ls   AA% %
A21A2)
__future__r   r$   r   r"   r   ImportError__all__r   r   r        r   <module>r.      s    " " " " " "  				 



MMMM   FFF %  :  @ IKK			s    ##