
    ԋg                    f    d dl mZ d dlZd dlZd dlZdZ ej                  e      ZddZ	 e	       Z
y)    )annotationsN)memory_limitMEMORY_LIMITc                 L   t        j                         j                  } t        j                  dk(  rbd}dD ]C  }	 t        |      5 }t        |j                               }ddd       dkD  r|}t        | |      } E |rt        j                  d|       t        j                  dk7  rL	 ddl}|j                  |j                        d   }d|cxk  r| k  rn | S t        j                  d|       |} | S | S # 1 sw Y   xY w# t        $ r Y w xY w# t        t         f$ r Y | S w xY w)	zGet the memory limit (in bytes) for this system.

    Takes the minimum value from the following locations:

    - Total system host memory
    - Cgroups limit (if set)
    - RSS rlimit (if set)
    linuxN)z+/sys/fs/cgroup/memory/memory.limit_in_bytesz0/sys/fs/cgroup/memory/memory.soft_limit_in_bytesz/sys/fs/cgroup/memory.maxz/sys/fs/cgroup/memory.highz/sys/fs/cgroup/memory.lowr   z?Setting system memory limit based on cgroup value defined in %swin32   z0Limiting system memory based on RLIMIT_RSS to %s)psutilvirtual_memorytotalsysplatformopenintreadmin	Exceptionloggerdebugresource	getrlimit
RLIMIT_RSSImportErrorOSError)limit	path_usedpathfcgroups_limitr   
hard_limits          2lib/python3.12/site-packages/distributed/system.pyr   r      s,    !!#))E ||w	
D$Z1$'MM   1$ $I}5E
 LLQ ||w
	!++H,?,?@CJ:%% L F
 # L5L7  Z
  & W% 	L	sA   DC5D(/D D 5C>	:D	DDD#"D#)returnr   )
__future__r   loggingr   r
   __all__	getLogger__name__r   r   r        r!   <module>r*      s9    "  
 
* 
		8	$2j ~r)   