
    Lg)                    j    d dl mZ d dlZd dlZd dlZ	 d dlZdZd Zd Z	 e	       Z
y# e$ r dZY w xY w)    )annotationsN)	cpu_count	CPU_COUNTc                    dD ]h  } 	 t        d| z        5 }t        |j                               }d d d        t        d| z        5 }t        |j                               }d d d        fc S  	 t        d      5 }|j                         j	                         j                  d      d   }d d d        j                  d      s| d}t        d|z        5 }t        t        |j                         j                  d	            \  }}||fcd d d        S # 1 sw Y   xY w# 1 sw Y   xY w# t        $ r Y 6w xY w# 1 sw Y   xY w# 1 sw Y   y
xY w# t        $ r Y y
w xY w)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.12/site-packages/dask/system.py_try_extract_cgroup_cpu_quotar      sF    2	:WDEAFFH F;gEF!QVVX G&=  2	%&!)//4R8J '""3'&<q)J+j89QQVVX^^C%89ME6&= :9 FEFF  		
 '& : 	   	s   D-DD-D!D-/E :1D=+,E 4E		E D	D-!D*	&D--	D:9D:=EE 	EE E 	E! E!c                 l   t        j                         } t        =	 t        t        j                         j                               }|dkD  rt        | |      } t        j                  dk(  r:t               \  }}|+|)t        j                  ||z        }|dkD  rt        | |      } | S # t        $ r Y Zw xY w)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)
    r   linux)osr   psutillenProcesscpu_affinityminr   sysplatformr   mathceil)countaffinity_countr   r   cgroups_counts        r   r   r   ,   s     LLNE 	 !1!>!>!@AN!E>2
 ||w57v!3 IIefn5Mq E=1L  		s   <B' '	B32B3)
__future__r   r$   r   r"   r   ImportError__all__r   r   r        r   <module>r.      sK    "  	 
 %:@ K	G  Fs   ( 22