o
    bi?                     @   s   d dl Z d dlZdd ZdS )    Nc                     s   t  dkrd t   v sJ zddl} W n ty#   d} Y nw d | r8z| jj W n	 ty7   Y nw  rK j	dkrM fdd}|| j_dS dS dS )aj  WSL's /proc/meminfo has an inconsistency where it
    nondeterministically omits a space after colons (after "SwapFree:"
    in my case).
    psutil then splits on spaces and then parses the wrong field,
    crashing on the 'int(fields[1])' expression in
    psutil._pslinux.virtual_memory().
    Workaround: We ensure there is a space following each colon.
    Linux	Microsoftr   Nopen_binaryc                    s\    | g|R i |}| dkr,| t | ddW  d    S 1 s'w   Y  |S )Nz/proc/meminfo   :s   : )ioBytesIOreadreplace)fnameargskwargsfpsutil_open_binary G/home/ubuntu/.local/lib/python3.10/site-packages/ray/_private/compat.pypsutil_open_binary_patched    s    z0patch_psutil.<locals>.psutil_open_binary_patched)
platformsystemlowerreleasepsutil._pslinuxImportError_pslinuxr   AttributeError__name__)psutilr   r   r   r   patch_psutil   s$   
r   )r   r   r   r   r   r   r   <module>   s    