관리-도구
편집 파일: resource_tracker.cpython-310.pyc
o 6��f # � @ s� d dl Z d dlZd dlZd dlZd dlZddlmZ ddlmZ g d�Ze ed�Z ejejfZ ddd � iZe jd krWd dlZd dlZe ed�rOe�deji� e�d eji� G dd� de�Ze� ZejZejZejZejZdd� ZdS )� N� )�spawn)�util)�ensure_running�register� unregister�pthread_sigmaskZnoopc C s d S �N� r r r �G/opt/alt/python310/lib64/python3.10/multiprocessing/resource_tracker.py�<lambda>! s r �posix� sem_unlinkZ 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__8 s zResourceTracker.__init__c C sn | j �* | jd u r W d � d S t�| j� d | _t�| jd� d | _W d � d S 1 s0w Y d S )Nr )r r �os�close�waitpidr r r r r �_stop= s �"�zResourceTracker._stopc C s | � � | jS r )r r r r r r �getfdJ s zResourceTracker.getfdc C s� | j �� | jdur?| �� r W d � dS t�| j� z| jdur)t�| jd� W n ty3 Y nw d| _d| _t� d� g }z |� tj� � � W n tyT Y nw d}t�� \}}zXzA|� |� t�� }|gt�� }|d|| g7 }ztr�t�tjt� t�|||�}W tr�t�tjt� ntr�t�tjt� w w W n t�|� � || _|| _W t�|� nt�|� w W d � dS 1 s�w 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 N s^ � �� � ���� "�zResourceTracker.ensure_runningc C s* z t �| jd� W dS ty Y dS w )z;Check that the pipe has not been closed by sending a probe.s PROBE:0:noop FT)r �writer �OSErrorr r r r r � s ��zResourceTracker._check_alivec C � | � d||� dS )z0Register name of resource with resource tracker.�REGISTERN��_send�r �name�rtyper r r r � � zResourceTracker.registerc C r2 )z2Unregister name of resource with resource tracker.� UNREGISTERNr4 r6 r r r r � r9 zResourceTracker.unregisterc C sb | � � d�|||��d�}t|�dkrtd��t�| j|�}|t|�ks/J d�|t|����d S )Nz{0}:{1}:{2} �asciii zmsg too longznbytes {0:n} but len(msg) {1:n})r �format�encode�len� ValueErrorr r0 r )r r+ r7 r8 �msg�nbytesr r r r5 � s �zResourceTracker._sendN)�__name__� __module__�__qualname__r r r r r r r r5 r r r r r 6 s @r c C s� t � t jt j� t � t jt j� trt �t jt� tj tj fD ]}z|�� W q ty0 Y qw dd� t �� D �}z�t| d��j}|D ]_}zF|�� �d��d�\}}}t �|d�}|du rgtd|� d|� ���|d krs|| �|� n|d kr|| �|� n|dkr�ntd| ��W qC ty� z tjt�� � W n Y Y qCw W d � n1 s�w Y W |�� D ]I\}}|r�z t�d t|�|f � W n ty� Y nw |D ])}z&zt | |� W n ty� } zt�d|| f � W Y d} ~ nd} ~ ww W q�w q�dS |�� D ]N\}}|�r&z t�d t|�|f � W n t�y% Y nw |D ]+}z(zt | |� W n t�yO } zt�d|| f � W Y d} ~ nd} ~ ww W �q(w �qw )zRun resource tracker.c S s i | ]}|t � �qS r )�set)�.0r8 r r r � <dictcomp>� s zmain.<locals>.<dictcomp>�rbr; �:NzCannot register z. for automatic cleanup: unknown resource type r3 r: ZPROBEzunrecognized command %rzQresource_tracker: There appear to be %d leaked %s objects to clean up at shutdownzresource_tracker: %r: %s)r'