Hacked By AnonymousFox
a
R�f�! � @ s� d dl Z d dlZd dlZd dlZd dlZddlmZ ddlmZ g d�Ze ed�Z
ejejfZ
ddd � iZe jd
kr�d dlZd dlZe�ejejd�� G dd
� d
e�Ze� ZejZejZejZejZdd� ZdS )� N� )�spawn)�util)�ensure_running�register�
unregister�pthread_sigmaskZnoopc C s d S �N� r
r
r
�E/opt/alt/python39/lib64/python3.9/multiprocessing/resource_tracker.py�<lambda>! � r �posix)Z semaphoreZ
shared_memoryc @ sL e Zd Zdd� Zdd� Zdd� Zdd� Zd d
� Zdd� Zd
d� Z dd� Z
dS )�ResourceTrackerc C s t �� | _d | _d | _d S r )� threadingZLock�_lock�_fd�_pid��selfr
r
r �__init__0 s
zResourceTracker.__init__c C sj | j �P | jd u r"W d � d S t�| j� d | _t�| jd� d | _W d � n1 s\0 Y d S )Nr )r r �os�close�waitpidr r r
r
r �_stop5 s
zResourceTracker._stopc C s | � � | jS r )r r r r
r
r �getfdB s zResourceTracker.getfdc C s� | j ��� | jdur~| �� r,W d � dS t�| j� z| jdurRt�| jd� W n tyf Y n0 d| _d| _t� d� g }z|�
tj�
� � W n ty� Y n0 d}t�� \}}z�z�|�
|� t�� }|gt�� }|d|| g7 }z:t�rt�tjt� t�|||�}W t�r@t�tjt� nt�r>t�tjt� 0 W n t�|� � Y n0 || _|| _W t�|� nt�|� 0 W d � n1 �s�0 Y dS )z�Make sure that resource tracker process is running.
This can be run from any process. Usually a child process will use
the resource created by its parent.Nr zUresource_tracker: process died unexpectedly, relaunching. Some resources might leak.z:from multiprocessing.resource_tracker import main;main(%d)z-c)r r �_check_aliver r r r �ChildProcessError�warnings�warn�append�sys�stderr�fileno� Exception�piper Zget_executabler Z_args_from_interpreter_flags�
_HAVE_SIGMASK�signalr � SIG_BLOCK�_IGNORED_SIGNALSZspawnv_passfds�SIG_UNBLOCK)r Zfds_to_pass�cmd�r�wZexe�args�pidr
r
r r F sN
�
zResourceTracker.ensure_runningc C s0 zt �| jd� W n ty& Y dS 0 dS dS )z;Check that the pipe has not been closed by sending a probe.s
PROBE:0:noop
FTN)r �writer �OSErrorr r
r
r r � s
zResourceTracker._check_alivec C s | � d||� dS )z0Register name of resource with resource tracker.�REGISTERN��_send�r �name�rtyper
r
r r � s zResourceTracker.registerc C s | � d||� dS )z2Unregister name of resource with resource tracker.�
UNREGISTERNr3 r5 r
r
r r � s zResourceTracker.unregisterc C sb | � � d�|||��d�}t|�dkr0td��t�| j|�}|t|�ks^J d�|t|����d S )Nz{0}:{1}:{2}
�asciii z
name too longznbytes {0:n} but len(msg) {1:n})r �format�encode�len�
ValueErrorr r0 r )r r+ r6 r7 �msg�nbytesr
r
r r4 � s �zResourceTracker._sendN)�__name__�
__module__�__qualname__r r r r r r r r4 r
r
r
r r . s
@r c
C s� t � t jt j� t � t jt j� tr2t �t jt� tj tj
fD ]$}z|�� W q> ty` Y q>0 q>dd� t
�� D �}�z�t| d���}|D ]�}z�|�� �d��d�\}}}t
�|d�}|du r�td|� d|� ���|d kr�|| �|� n2|d
k�r|| �|� n|dk�rntd| ��W q� t�yR ztjt�� � W n Y n0 Y q�0 q�W d � n1 �sl0 Y W |�� D ]�\}}|�r�zt�d
t|�|f � W n t�y� Y n0 |D ]X}zNzt
| |� W n8 t�y } zt�d|| f � W Y d} ~ n
d} ~ 0 0 W n0 �qq�n�|�� D ]�\}}|�rhzt�d
t|�|f � W n t�yf Y n0 |D ]X}zNzt
| |� W n8 t�y� } zt�d|| f � W Y d} ~ n
d} ~ 0 0 W n0 �ql�q*0 dS )zRun resource tracker.c S s i | ]}|t � �qS r
)�set)�.0r7 r
r
r �
<dictcomp>� r
zmain.<locals>.<dictcomp>�rbr9 �:NzCannot register z. for automatic cleanup: unknown resource type r2 r8 ZPROBEzunrecognized command %rzQresource_tracker: There appear to be %d leaked %s objects to clean up at shutdownzresource_tracker: %r: %s)r'