Ë
    ÄÓ^j	  ã                  ó,   — d Z ddlmZ ddgZdd„Zd	d„Zy)
z©Helpers for inspecting Linux process state from ``/proc``.

These are intentionally agent-agnostic so they can be reused outside of
``torch.distributed.elastic.agent``.
é    )ÚannotationsÚread_proc_stateÚis_uninterruptible_statec                óô   — 	 t        d| › d�«      5 }|j                  «       }ddd«       j                  d«      }|dk(  ry||dz   d j                  «       }|sy|d   S # 1 sw Y   Œ>xY w# t        $ r Y yw xY w)aŒ  Read the process state char from ``/proc/<pid>/stat``. Linux-only.

    Returns the single-letter state (e.g. ``'R'``, ``'S'``, ``'D'``,
    ``'Z'``) or ``None`` if the file is unreadable (non-Linux, process
    gone, permission denied, or parse error). The ``comm`` field can
    contain spaces and parentheses, so the parser keys off the last
    ``)`` rather than splitting on whitespace.
    z/proc/z/statNú)éÿÿÿÿé   r   )ÚopenÚreadÚrfindÚsplitÚOSError)ÚpidÚfÚdataÚrparenÚrests        úx/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/torch/distributed/elastic/utils/process_state.pyr   r      sŽ   € ðÜ�F˜3˜%˜uÐ%Ó&ð 	¨!Ø—6‘6“8ˆD÷	à—‘˜C“ˆØ�RŠ<Øð �F˜Q‘J�LÐ!×'Ñ'Ó)ˆÙØØ�A‰wˆ÷	ð 	ûô ò Ùðús3   ‚A+ ‘A¢A+ ÁA+ ÁA+ ÁA(Á$A+ Á+	A7Á6A7c                ó0   — | duxr | j                  d«      S )zúReturn True if ``state`` is Linux uninterruptible sleep ('D').

    Includes the ``'D+'`` (foreground) variant; the state field is
    a single char in the kernel format we read, but we accept any
    string that starts with ``'D'`` defensively.
    NÚD)Ú
startswith)Ústates    r   r   r   /   s   € ð ˜ÐÒ6 ×!1Ñ!1°#Ó!6Ð6ó    N)r   ÚintÚreturnú
str | None)r   r   r   Úbool)Ú__doc__Ú
__future__r   Ú__all__r   r   © r   r   ú<module>r"      s&   ðñõ #ð Ð8Ð
9€óô27r   