Ë
    u™ãj¸  ã                  óx   — d Z ddlmZ ddlZddlZdd„Zdd„Zdd„Zdd„Z ej                  d¬	«      dd
„«       Z
y)am  
Detection of the CPU allocation actually available to this process.

Used to bound the default worker count for parallel I/O, so that a default
:func:`~pandas.read_csv` does not oversubscribe a machine on which the process
has been given only a slice of the CPUs -- a CPU affinity mask, or a cgroup CPU
quota as set by ``docker --cpus`` and Kubernetes CPU limits.
é    )ÚannotationsNc                óÂ   — 	 t        | d¬«      5 }t        |j                  «       j                  «       «      cd d d «       S # 1 sw Y   y xY w# t        t
        f$ r Y y w xY w©Nzutf-8)Úencoding)ÚopenÚintÚreadÚstripÚOSErrorÚ
ValueError©ÚpathÚfhs     ú]/var/www/html/python-recuperauto-other/env/lib/python3.12/site-packages/pandas/compat/_cpu.pyÚ_read_sysfs_intr      sS   € ðÜ�$ Ô)ð 	*¨RÜ�r—w‘w“y—‘Ó(Ó)÷	*÷ 	*ò 	*ûä”ZÐ ò Ùðús-   ‚A �'A ¶	A Á A	ÁA Á	A ÁAÁAc                ó°   — 	 t        | d¬«      5 }|j                  «       j                  «       cd d d «       S # 1 sw Y   y xY w# t        t        f$ r Y y w xY wr   )r   r	   r
   r   r   r   s     r   Ú_read_sysfs_strr      sN   € ð
Ü�$ Ô)ð 	%¨RØ—7‘7“9—?‘?Ó$÷	%÷ 	%ò 	%ûä”ZÐ ò Ùðús*   ‚A �7­	A ·A ¼A Á A ÁAÁAc                óÐ   — | j                  «       }|r|d   dk(  ry	 t        |d   «      }t        |«      dkD  rt        |d   «      nd}|dkD  r
|dkD  r||z  S y# t        $ r Y yw xY w)z×
    CPU count from a cgroup v2 ``cpu.max`` value.

    The format is ``"<quota> <period>"`` (both in microseconds) or ``"max"`` when
    the CPU time is unlimited; returns ``None`` when unlimited or malformed.
    r   ÚmaxNé   i † )Úsplitr   Úlenr   )ÚtextÚpartsÚquotaÚperiods       r   Ú_parse_cgroup_v2_quotar   $   s{   € ð �J‰J‹L€EÙ�E˜!‘H Ò%ØðÜ�E˜!‘H“ˆÜ"% e£*¨q¢.”�U˜1‘X”°fˆð ˆq‚y�V˜a’ZØ�v‰~ÐØøô	 ò Ùðús   �,A Á	A%Á$A%c                 ó†   — t        d«      } | �t        | «      S t        d«      }t        d«      }|r|dkD  r|r
|dkD  r||z  S y)zECPUs allowed by the process's cgroup CFS quota, or None if unlimited.z/sys/fs/cgroup/cpu.maxNz#/sys/fs/cgroup/cpu/cpu.cfs_quota_usz$/sys/fs/cgroup/cpu/cpu.cfs_period_usr   )r   r   r   )r   r   r   s      r   Ú_cgroup_cpu_quotar   8   sT   € ô Ð3Ó4€DØÐÜ% dÓ+Ð+äÐAÓB€EÜÐCÓD€FÙ�˜’™v¨&°1ª*Ø�v‰~ÐØó    r   )Úmaxsizec                 ó  — g } t        t        d«      r.	 | j                  t        t        j                  d«      «      «       t        «       }|�$| j                  t        dt        |«      «      «       | rt        | «      S dS # t
        $ r Y ŒJw xY w)a%  
    Number of CPUs the process may actually use, or None if unconstrained.

    Takes the tighter of the CPU affinity mask (``taskset``, SLURM cpusets) and
    the cgroup CFS quota (Docker ``--cpus``, Kubernetes CPU limits), so a default
    worker count does not oversubscribe a restricted environment.  Returns
    ``None`` only where neither limit is probed -- in practice macOS and
    Windows.  macOS exposes no affinity mask at all; Windows does (via
    ``GetProcessAffinityMask`` and job-object rate limits) but it is not
    implemented here, so a restricted Windows process falls back to the
    logical CPU count clamped by ``_MAX_DEFAULT_WORKERS``.
    On Linux ``sched_getaffinity`` always succeeds, so an unconstrained box
    reports its full logical CPU count rather than ``None``.

    Cached for the process lifetime: the CPU allocation is static in practice
    (affinity is normally set once at startup, and a live quota change via
    ``docker update`` or an in-place pod resize is rare), and this is on the
    ``read_csv`` hot path.
    Úsched_getaffinityr   Nr   )
ÚhasattrÚosÚappendr   r#   r   r   r   r   Úmin)Úlimitsr   s     r   Úavailable_cpu_countr)   G   s�   € ð* €FÜŒrÐ&Ô'ð	Ø�M‰Mœ#œb×2Ñ2°1Ó5Ó6Ô7ô Ó€EØÐØ�‰”c˜!œS ›ZÓ(Ô)Ù Œ3ˆv‹;Ð* dÐ*øô ò 	Ùð	ús   ”-B  Â 	BÂB)r   ÚstrÚreturnú
int | None)r   r*   r+   z
str | None)r   r*   r+   úfloat | None)r+   r-   )r+   r,   )Ú__doc__Ú
__future__r   Ú	functoolsr%   r   r   r   r   Ú	lru_cacher)   © r    r   ú<module>r3      sJ   ðñõ #ã Û 	óó	óó(ð €×Ñ˜QÔò+ó  ñ+r    