o
    Zc                     @   sb  d dl mZ d dlZd dlZd dlZd dlZzd dlZW n ey)   d dlZY nw zd dl	m
Z
 W n ey?   dd Z
Y nw d dlmZmZmZmZmZmZmZmZmZmZmZmZmZ ddlmZ g d	Zd
ZdZd ZdZdZ dZ!dZ"dZ#dZ$dZ%dZ&da'da(dd Z)dd Z*dd Z+dd Z,dd Z-dd Z.d d! Z/d*d"d#Z0d$d% Z1d&d' Z2d(d) Z3dS )+    )absolute_importN)_args_from_interpreter_flagsc                  C   st   ddddddddd	d
d
} g }|   D ]\}}ttj|}|dkr*|d||   qtjD ]	}|d|  q.|S )zrReturn a list of command-line arguments reproducing the current
        settings in sys.flags and sys.warnoptions.dOBsSEvbR3)
debugoptimizedont_write_bytecodeno_user_siteno_siteignore_environmentverbosebytes_warninghash_randomizationpy3k_warningr   -z-W)itemsgetattrsysflagsappendwarnoptions)flag_opt_mapargsflagoptr
    r#   C/var/www/chikooza/env/lib/python3.10/site-packages/billiard/util.pyr      s(   
r   )_afterfork_registry_afterfork_counter_exit_function_finalizer_registry_finalizer_counterFinalizeForkAwareLocalForkAwareThreadLockget_temp_dir
is_exitingregister_after_fork_run_after_forkers_run_finalizers   )	get_errno)	sub_debugr   infosub_warning
get_loggerlog_to_stderrr-   r/   r.   r*   r,   r+   SUBDEBUG
SUBWARNING      
            (   multiprocessingz+[%(levelname)s/%(processName)s] %(message)sFc                 O   &   t rt jt| g|R i | d S d S N)_loggerlogr9   msgr    kwargsr#   r#   r$   r4   a      r4   c                 O   rC   rD   )rE   rF   DEBUGrG   r#   r#   r$   r   f   rJ   r   c                 O   rC   rD   )rE   rF   INFOrG   r#   r#   r$   r5   k   rJ   r5   c                 O   rC   rD   )rE   rF   r:   rG   r#   r#   r$   r6   p   rJ   r6   c                 O   rC   rD   )rE   rF   WARNINGrG   r#   r#   r$   warningt   rJ   rN   c                 O   rC   rD   )rE   rF   ERRORrG   r#   r#   r$   errorx   rJ   rP   c                  C   s   ddl } |   zMtsH| tadt_| td | td t	t
dr/t
t t
t n t
jtdi f t
jtdi f W |   tS W |   tS W |   tS |   w )z0
    Returns logger used by multiprocessing
    r   Nr9   r:   
unregisterr#   )logging_acquireLockrE   	getLoggerLOGGER_NAME	propagateaddLevelNamer9   r:   hasattratexitrQ   r'   register_exithandlersremover   _releaseLock)rR   r#   r#   r$   r7   }   s,   



r7   c                 C   sJ   ddl }t }|t}| }|| || | r!||  dat	S )zB
    Turn on logging and add a handler which prints to stderr
    r   NT)
rR   r7   	FormatterDEFAULT_LOGGING_FORMATStreamHandlersetFormatter
addHandlersetLevel_log_to_stderrrE   )levelrR   logger	formatterhandlerr#   r#   r$   r8      s   



r8   c                  C   s   t jds	t z:dt jv r-t } | d | d}| 	d}|
t| |d W S t }tjd}|
tt| |jW S  tyM   t w )zE
    Return the current value of the parent process death signal
    linuxcffiint prctl (int __option, ...);zint *Nr   	libc.so.6)r   platform
startswithOSErrormodulesrj   FFIcdefnewdlopenprctlPR_GET_PDEATHSIGctypesc_intcdllLoadLibrarybyrefvalue	Exception)ffiargCsiglibcr#   r#   r$   get_pdeathsig   s"   




r   c                 C   s   t jds	t z/dt jv r*t }|d |d}|	t
|d|  W dS tjd}|	t
|  W dS  tyB   t w )am  
    Set the parent process death signal of the calling process to sig
    (either a signal value in the range 1..maxsig, or 0 to clear).
    This is the signal that the calling process will get when its parent dies.
    This value is cleared for the child of a fork(2) and
    (since Linux 2.4.36 / 2.6.23) when executing a set-user-ID or set-group-ID binary.
    ri   rj   rk   Nintrl   )r   rm   rn   ro   rp   rj   rq   rr   rt   ru   PR_SET_PDEATHSIGcastrw   ry   rz   r}   )r   r~   r   r   r#   r#   r$   set_pdeathsig   s   


r   c                    s   t   fdd}|S )z&
    Automatic retry after EINTR.
    c               
      sJ   	 z | i |W S  t y# } zt|tjkr W Y d }~nd }~ww qrD   )ro   r3   errnoEINTR)r    rI   excfuncr#   r$   wrapped   s   z_eintr_retry.<locals>.wrapped)	functoolswraps)r   r   r#   r   r$   _eintr_retry   s   r   rD   )4
__future__r   r   r   r   rY   rj   ImportErrorrw   
subprocessr   multiprocessing.utilr%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   compatr3   __all__rv   r   NOTSETr9   rK   rL   r:   rM   rO   rU   r_   rE   rd   r4   r   r5   r6   rN   rP   r7   r8   r   r   r   r#   r#   r#   r$   <module>   sT   <	
