Your IP : 3.142.174.8


Current Path : /opt/alt/python310/lib64/python3.10/multiprocessing/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/multiprocessing/__pycache__/util.cpython-310.opt-2.pyc

o

6��f�6�@s�ddlZddlZddlZddlZddlZddlZddlmZddlm	Z	gd�Z
dZdZdZ
dZd	Zd
ZdZdadad
d�Zdd�Zdd�Zdd�Zdd�Zd?dd�Zdd�Zdd�Ze�Zdd�Zdd �Ze��Z e�!�Z"d!d"�Z#d#d$�Z$iZ%e�!�Z&Gd%d&�d&e'�Z(d?d'd(�Z)d)d*�Z*da+eee)e	j,e	j-fd+d,�Z.e�/e.�Gd-d.�d.e'�Z0Gd/d0�d0ej1�Z2ze�3d1�Z4Wne5y�d2Z4Ynwd3d4�Z6d5d6�Z7d7d8�Z8d9d:�Z9d;d<�Z:d=d>�Z;dS)@�N)�_args_from_interpreter_flags�)�process)�	sub_debug�debug�info�sub_warning�
get_logger�
log_to_stderr�get_temp_dir�register_after_fork�
is_exiting�Finalize�ForkAwareThreadLock�ForkAwareLocal�close_all_fds_except�SUBDEBUG�
SUBWARNING��
���multiprocessingz+[%(levelname)s/%(processName)s] %(message)sFcG� trtjt|g|�R�dSdS�N)�_logger�logr��msg�args�r �;/opt/alt/python310/lib64/python3.10/multiprocessing/util.pyr,��rcGrr)rr�DEBUGrr r r!r0r"rcGrr)rr�INFOrr r r!r4r"rcGrr)rrrrr r r!r8r"rcCs�	ddl}|��zAts=|�t�adt_ttd�r$t�t	�t�
t	�n tj�t	dif�tj�
t	dif�W|��tSW|��tSW|��tS|��w)Nr�
unregisterr )�loggingZ_acquireLockrZ	getLogger�LOGGER_NAMEZ	propagate�hasattr�atexitr%�_exit_function�registerZ
_exithandlers�remove�appendZ_releaseLock)r&r r r!r	<s*


��
�r	cCsL	ddl}t�}|�t�}|��}|�|�|�|�|r"|�|�dat	S)NrT)
r&r	Z	Formatter�DEFAULT_LOGGING_FORMATZ
StreamHandlerZsetFormatterZ
addHandlerZsetLevel�_log_to_stderrr)�levelr&ZloggerZ	formatterZhandlerr r r!r
Ws



r
cCs tjdkrdSttd�rdSdS)NZlinuxTZgetandroidapilevelF)�sys�platformr(r r r r!�#_platform_supports_abstract_socketsls


r3cCsD|sdSt|t�r|ddkSt|t�r|ddkStd|�d���)NFr�zaddress type of z
 unrecognized)�
isinstance�bytes�str�	TypeError)Zaddressr r r!�is_abstract_socket_namespacets

r9cCs*||�t��}|durd|jd<dSdS)N�tempdir)r�current_process�_config)�rmtreer:r;r r r!�_remove_temp_dir�s
�r>cCsft��j�d�}|dur1ddl}ddl}|jdd�}td|�tdt	|j
|fdd�|t��jd<|S)Nr:rzpymp-)�prefixzcreated temp directory %si����)r�exitpriority)rr;r<�get�shutil�tempfileZmkdtemprrr>r=)r:rBrCr r r!r�s
�rcCsftt���}|��|D]$\\}}}}z||�Wqty0}ztd|�WYd}~qd}~wwdS)Nz after forker raised exception %s)�list�_afterfork_registry�items�sort�	Exceptionr)rF�indexZident�func�obj�er r r!�_run_after_forkers�s���rMcCs|ttt�t|�|f<dSr)rE�next�_afterfork_counter�id)rKrJr r r!r�src@sDeZdZ	d
dd�Zdeeejfdd�Zdd�Z	d	d
�Z
dd�ZdS)rr NcCs�|durt|t�std�|t|����|durt�||�|_n|dur'td��||_	||_
|p0i|_|tt
�f|_t��|_|t|j<dS)Nz3Exitpriority ({0!r}) must be None or int, not {1!s}z+Without object, exitpriority cannot be None)r5�intr8�format�type�weakref�ref�_weakref�
ValueError�	_callback�_args�_kwargsrN�_finalizer_counter�_key�os�getpid�_pid�_finalizer_registry)�selfrK�callbackr�kwargsr@r r r!�__init__�s ��

zFinalize.__init__cCs�	z||j=Wnty|d�YdSw|j|�kr#|d�d}n|d|j|j|j�|j|ji|j��}d|_|_|_|_|_|S)Nzfinalizer no longer registeredz+finalizer ignored because different processz/finalizer calling %s with args %s and kwargs %s)r\�KeyErrorr_rXrYrZrV)raZwrr`rr^�resr r r!�__call__�s"���zFinalize.__call__cCsF	zt|j=Wn
tyYdSwd|_|_|_|_|_dSr)r`r\rerVrXrYrZ�rar r r!�cancel�s��zFinalize.cancelcCs	|jtvSr)r\r`rhr r r!�still_active�s
zFinalize.still_activec	Cs�z|��}Wn
ttfyd}Ynw|durd|jjSd|jjt|jd|j�f}|jr8|dt|j�7}|j	rD|dt|j	�7}|j
ddurV|dt|j
d�7}|dS)	Nz<%s object, dead>z<%s object, callback=%s�__name__z, args=z	, kwargs=rz, exitpriority=�>)rV�AttributeErrorr8�	__class__rk�getattrrXrYr7rZr\)rarK�xr r r!�__repr__�s$��zFinalize.__repr__)r NN)rk�
__module__�__qualname__rdr`rr]r^rgrirjrqr r r r!r�s

�rc	s�	tdurdS�durdd��n�fdd���fdd�tt�D�}|jdd�|D]'}t�|�}|durPtd|�z|�Wq)tyOd	dl}|��Yq)wq)�dur[t��dSdS)
NcSs|dduS�Nrr ��pr r r!�<lambda>sz!_run_finalizers.<locals>.<lambda>cs|dduo|d�kSrtr ru)�minpriorityr r!rw�csg|]}�|�r|�qSr r )�.0�key)�fr r!�
<listcomp>#ryz#_run_finalizers.<locals>.<listcomp>T)�reversez
calling %sr)	r`rDrGrArrH�	traceback�	print_exc�clear)rx�keysr{�	finalizerrr )r|rxr!�_run_finalizerss,



���r�cCs	tptduSr)�_exitingr r r r!r
8sr
cCs�tsBda|d�|d�|d�|�dur9|�D]}|jr(|d|j�|j��q|�D]}|d|j�|��q,|d�|�dSdS)NTzprocess shutting downz2running all "atexit" finalizers with priority >= 0rz!calling terminate() for daemon %szcalling join() for process %sz)running the remaining "atexit" finalizers)r�Zdaemon�nameZ_popenZ	terminate�join)rrr��active_childrenr;rvr r r!r*@s"	


�


�r*c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
rcCs.t��|_|jj|_|jj|_t|tj�dSr)�	threadingZLock�_lock�acquire�releaserr�_at_fork_reinitrhr r r!rdqs


zForkAwareThreadLock.__init__cCs|j��dSr)r�r�rhr r r!r�wsz#ForkAwareThreadLock._at_fork_reinitcC�
|j��Sr)r��	__enter__rhr r r!r�zs
zForkAwareThreadLock.__enter__cGs|jj|�Sr)r��__exit__)rarr r r!r�}�zForkAwareThreadLock.__exit__N)rkrrrsrdr�r�r�r r r r!rps
rc@seZdZdd�Zdd�ZdS)rcCst|dd��dS)NcSr�r)�__dict__r�)rKr r r!rw�s
z)ForkAwareLocal.__init__.<locals>.<lambda>)rrhr r r!rd�szForkAwareLocal.__init__cCst|�dfS)Nr )rSrhr r r!�
__reduce__�r�zForkAwareLocal.__reduce__N)rkrrrsrdr�r r r r!r�sr�SC_OPEN_MAX�cCsNt|�dtg}|��tt|�d�D]}t�||d||d�qdS)N���r)rD�MAXFDrG�range�lenr]�
closerange)�fds�ir r r!r�s
�rc	Cs�tjdurdSztj��WnttfyYnwzt�tjtj�}zt|ddd�t_WWdSt�|��ttfyDYdSw)Nzutf-8F)�encoding�closefd)	r1�stdin�close�OSErrorrWr]�open�devnull�O_RDONLY)�fdr r r!�_close_stdin�s"
�
�r�c	CsPztj��WnttfyYnwztj��WdSttfy'YdSwr)r1�stdout�flushrmrW�stderrr r r r!�_flush_std_streams�s��r�cCs�ddl}tttt|���}t��\}}z(|�|t�|�gd|dddddddd||ddddddd�Wt�	|�t�	|�St�	|�t�	|�w)NrTr�F)
�_posixsubprocess�tuple�sorted�maprQr]�pipeZ	fork_exec�fsencoder�)�pathrZpassfdsr�Zerrpipe_readZ
errpipe_writer r r!�spawnv_passfds�s�

�r�cGs	|D]}t�|�qdSr)r]r�)r�r�r r r!�	close_fds�s�r�cCs\	ddlm}t��ddlm}|j��ddlm}|j	��t
�|��|��dS)Nr)�support)�
forkserver)�resource_tracker)
�testr�rZ_cleanuprr�Z_forkserverZ_stopr�Z_resource_trackerr�Z
gc_collectZ
reap_children)r�r�r�r r r!�_cleanup_tests�s

r�r)<r]�	itertoolsr1rTr)r��
subprocessr�r�__all__ZNOTSETrr#r$rr'r.rr/rrrrr	r
r3r9Zabstract_sockets_supportedr>rZWeakValueDictionaryrE�countrOrMrr`r[�objectrr�r
r�r�r;r*r+rZlocalr�sysconfr�rHrr�r�r�r�r�r r r r!�<module>sr	

		
V,
�
*
�


?>