
    Sf                        d dl Z d dlZd dlZd dlZd dlZd dlmZ ej        dk    r	 d dlZn# e	$ r	 d dl
mZ Y nw xY wdZ	 d dlZn# e	$ r dZY nw xY wd dlmZ eeefZ eed          rej        Zd Znd Z	 ej        Zej        Zn# e$ r d	 Z e            \  ZZ[Y nw xY wd
 Zd"dZd Z	 ej        Zd"dZn# e$ r
 d Zd"dZY nw xY wd Z	 d dlZd Z n# e	$ r d Z Y nw xY wej        dk    rd Z!d Z"nd dlm#Z# d dl$m$Z$m%Z%m&Z& d Z"d Z!dZ'dZ(ej        dk    r	 d dl)Z)n# e	$ r dZ)Y nw xY wd Z*dS 	 d dlm+Z+m,Z, n# e	$ r dxZ+Z,Y nw xY wdej        v sej        dk    rd Z-nd  Z-d! Z*dS )#    N)zip_longestwin32)r   )UnsupportedOperationwritec                 2    t          | ||d                    S N)	__write__fdbufoffsets      A/var/www/html/env/lib/python3.11/site-packages/billiard/compat.pysend_offsetr      s    S\***    c                      t          d          )Nr   NotImplementedErrorr
   s      r   r   r   "   s    !-000r   c                  b    t          j                    dk    rdndfd} fd}| |fS )Nmbcsstrictsurrogateescapec                     t          | t                    r| S t          | t                    r|                               S t	          dt          |           j        z            )a  
            Encode filename to the filesystem encoding with 'surrogateescape'
            error handler, return bytes unchanged. On Windows, use 'strict'
            error handler if the file system encoding is 'mbcs' (which is the
            default encoding).
            expect bytes or str, not %s)
isinstancebytesstrencode	TypeErrortype__name__filenameencodingerrorss    r   fsencodez_fscodec.<locals>.fsencode1   sh     (E** ;Hc** ;x888 ="&x.."9!: ; ; ;r   c                     t          | t                    r| S t          | t                    r|                               S t	          dt          |           j        z            )a  
            Decode filename from the filesystem encoding with 'surrogateescape'
            error handler, return str unchanged. On Windows, use 'strict' error
            handler if the file system encoding is 'mbcs' (which is the default
            encoding).
            r   )r   r   r   decoder   r   r    r!   s    r   fsdecodez_fscodec.<locals>.fsdecode@   sh     (C(( ;He,, ;x888 ="&x.."9!: ; ; ;r   )sysgetfilesystemencoding)r%   r(   r#   r$   s     @@r   _fscodecr+   *   sr    ,..vFF&F	; 	; 	; 	; 	; 	;	; 	; 	; 	; 	; 	; !!r   c                     t          | t          j                  r| S 	 |                                 S # t          $ r Y dS w xY w)z3Get object fileno, or :const:`None` if not defined.N)r   numbersIntegralfilenoFILENO_ERRORS)fs    r   maybe_filenor2   U   sQ    !W%&& xxzz   s   2 
A A c                     	 t          j        d          S #  Y nxY wt          | S t          j        t          j                  d         }|t          j        k    r| S |S )zReturn the maximum number of open file descriptors
    on this system.

    :keyword default: Value returned if there's no file
                      descriptor limit.

    SC_OPEN_MAXN   )ossysconfresource	getrlimitRLIMIT_NOFILERLIM_INFINITY)defaultfdmaxs     r   	get_fdmaxr>   _   s`    z-(((x566q9E&&&Ls    c                 <    t                      fd| D             S )z7Return all unique elements in ``it``, preserving order.c              3   N   K   | ]}|v                     |          p|V   d S r   )add).0objseens     r   	<genexpr>zuniq.<locals>.<genexpr>v   s6      BBS#T//DHHSMM S////BBr   )set)itrD   s    @r   uniqrH   s   s&    55DBBBBBBBBBr   c                 
   d | pg D             } t          t          t          d                              D ]I}|| vrC	 t          j        |           # t
          $ r }|j        t          j        k    r Y d }~Ad }~ww xY wJd S )Nc                 J    g | ] }t          |          t          |          !S r   )r2   rB   r1   s     r   
<listcomp>z"close_open_fds.<locals>.<listcomp>   s6     F F Fa)D Q)D)D)Dr      r<   )reversedranger>   r6   closeOSErrorerrnoEBADF)keepr   excs      r   close_open_fdsrW      s    F F*"F F F54!8!8!899:: 	 	B~~HRLLLL   yEK// 0//// 	 	s    A
A?A::A?c                     t          t          | |                    D ]D}	 t          j        |           # t          $ r }|j        t
          j        k    r Y d }~=d }~ww xY wd S r   )rO   rP   r6   rQ   rR   rS   rT   )fd_lowfd_highr   rV   s       r   
closeranger[   }   s    51122 	 	B   9++ ,++++	 	s   6
A  AA c                 f   t          t          t          d t          t          | pg           D                                           } t          d          }t          dg| z             t          | |gz             }}t          ||          D ]!\  }}|dz   |k    rt          |dz   |           "d S )Nc              3      K   | ]}||V  	d S r    rK   s     r   rE   z!close_open_fds.<locals>.<genexpr>   s+        
  
A 
  
r   rM   rN   r5   )	listrH   sortedmapr2   r>   iterr   r[   )rU   maxfdkLkHlowhighs         r   rW   rW      s    D  
  
<44 
  
  
 
 
     $'''rdTk""D$8$8B$R,, 	* 	*ICQw$37D)))	* 	*r   c                 4    	 | j         S # t          $ r Y dS w xY w)zV:exc:`socket.error` and :exc:`IOError` first got
    the ``.errno`` attribute in Py2.7r   )rS   AttributeError)rV   s    r   	get_errnork      s1    y   qqs   	 
c                    t          |          }t          j                    \  }}	 |t          |           gdt	          |          d d dddddd||ddg}t
          j        dk    r|                    d           t
          j        dk    r|                    d           |                    d            t
          j        dk    r|                    t          j
                   t          j        | t          j        |           t          j        |           S # t          j        |           t          j        |           w xY w)NTr_   F)      )rm   	   )NNNr_   )ra   r6   piper%   tupler)   version_infoappendextend
subprocess
_USE_VFORK_posixsubprocess	fork_execrQ   )pathargspassfdserrpipe_readerrpipe_writes        r   spawnv_passfdsr~      s'   //&(gii#m	$x~~&eGnndDBBBmuD 7**B6))2333KK7**J1222#-t4H\"""H]#### H\"""H]####s   CD *Ec                 L   t           j        dk    r5|t          t           j                  t          t           j                  gz   }t          j                    }|sIt          t          d |D                                  t          j	        t          |           |           |S )Nr   c              3      K   | ]}||V  	d S r   r^   rK   s     r   rE   z!spawnv_passfds.<locals>.<genexpr>   s'      &?&?QQ&?q&?&?&?&?&?&?r   )rU   )r)   platformr2   stdoutstderrr6   forkrW   ra   execvr%   )ry   rz   r{   pids       r   r~   r~      s    <7"" SZ((SZ((! G gii 	+&?&?'&?&?&? ? ?@@@@HXd^^T***
r   c                      t          d          )Nz$setblocking not implemented on win32r   )handleblockings     r   setblockingr      s    !"HIIIr   c                      t          d          )Nz#isblocking not implemented on win32r   r   s    r   
isblockingr      s    !"GHHHr   )
O_NONBLOCK)fcntlF_GETFLF_SETFLc                 >    t          | t                    t          z   S r   )r   r   r   r   s    r   r   r      s    &'**Z788r   c                     t          | t          d          }t          | t          |r|t           z  n	|t          z             d S )Nr   )r   r   r   r   )r   r   flagss      r   r   r      sM    fgq))G%-EEj[!!5:3E	
 	
 	
 	
 	
r   z
On Windows, the ability to inspect memory usage requires the psutil library.

You can install it using pip:

    $ pip install psutil
z
Your platform ({0}) does not seem to have the `resource.getrusage' function.

Please open an issue so that we can add support for this platform.
c                      t           &t          t                                                    t	          t          j        t          j                                                              d         dz            S )Nr         @)	psutilImportErrorE_PSUTIL_MISSINGstripintProcessr6   getpidmemory_infor^   r   r   mem_rssr      sV    >.44667776>")++..::<<Q?&HIIIr   )	getrusageRUSAGE_SELFbsddarwinc                 &    t          |           dz  S )Nr   r   vs    r   maxrss_to_kbr     s    q66F?"r   c                      t          |           S r   r   r   s    r   r   r     s    q66Mr   c                      t           Ct          t                                                              t
          j                            t          t          t                    j
                  S r   )r8   r   E_RESOURCE_MISSINGr   formatr)   r   r   r   r   	ru_maxrssr^   r   r   r   r     sL    06688??MMNNNIk22<===r   r   ).rS   r-   r6   ru   r)   	itertoolsr   r   _winapir   _multiprocessingr   r8   ior   rj   
ValueErrorr0   hasattrr   r	   r   r%   r(   r+   r2   r>   rH   r[   rW   rk   rw   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r^   r   r   <module>r      s8     				     



 ! ! ! ! ! !<76 6 6 6555555556 GOOOO   HHH $ # # # # #-AB 72w 	1I+ + + +
1 1 1,{H{HH ) ) )%" %" %"N "HhS)X     (C C C J,	 	 	 	 	+  * * *  	* 	* 	* 	* 	* 	**B  #$ $ $ $ $        H <7J J JI I I I ----------9 9 9
 
 
   <7   J J J J J'333333333 ' ' '"&&	KKK'  8 8	# 	# 	# 	#	 	 	> > > > >sx   , :: A AA8B B B .B: :C	C	C C#"C#D# #D-,D-6D? ?	E
E