U
    /e                     @   sT   d dl Z d dlZd dlZzd dlZW n ek
r<   dZY nX dZdd Ze ZdS )    N)	cpu_count	CPU_COUNTc               
   C   s   t  } tdk	rLz&tt  }|dkr4t| |} W n tk
rJ   Y nX tj	dkrdD ]}zrt
d| }t| }W 5 Q R X t
d| }t| }W 5 Q R X t|| }|dkrt| |} W  qW qZ tk
r   Y qZX qZ| 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)zcpuacct,cpuzcpu,cpuacctz"/sys/fs/cgroup/%s/cpu.cfs_quota_usz#/sys/fs/cgroup/%s/cpu.cfs_period_us)osr   psutillenProcessZcpu_affinitymin	Exceptionsysplatformopenintreadmathceil)countZaffinity_countdirnamefZquotaZperiodZcgroups_count r   //tmp/pip-unpacked-wheel-dbjnr7gq/dask/system.pyr      s,    	


r   )r   r   r   r   ImportError__all__r   r   r   r   r   r   <module>   s   
(