
    0Fie                    j    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
dS )    )annotationsN)memory_limitMEMORY_LIMITreturnintc                 t   t          j                    j        } t          j        dk    rd}dD ]s}	 t          |          5 }t          |                                          }ddd           n# 1 swxY w Y   |dk    r|}t          | |          } d# t          $ r Y pw xY w|rt                              d|           t          j        dk    rj	 ddl}|                    |j                  d         }d|cxk     r| k     r n nt                              d|           |} n# t          t           f$ r Y nw xY w| S )	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openr   readmin	Exceptionloggerdebugresource	getrlimit
RLIMIT_RSSImportErrorOSError)limit	path_usedpathfcgroups_limitr   
hard_limits          2lib/python3.11/site-packages/distributed/system.pyr   r      s    !##)E |w	
 	 	D$ZZ 21$'MMM2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1$$ $I}55E    	LLQ   |w
	OOO!++H,?@@CJ:%%%%%%%%%F
   #W% 	 	 	D	 LsG   B"A-!B-A1	1B4A1	5B
BBAD! !D54D5)r   r   )
__future__r   loggingr   r   __all__	getLogger__name__r   r   r        r"   <module>r*      sq    " " " " " "  



 
* 
	8	$	$2 2 2 2j |~~r)   