관리-도구
편집 파일: resource_tracker.cpython-310.opt-2.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 �� | jd ur@| �� r W d � d S t�| j� z| jd ur*t�| jd� W n ty4 Y nw d | _d | _t� d� g }z |� tj� � � W n tyU 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 � d S 1 s�w Y d S )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 )Ns PROBE:0:noop FT)r �writer �OSErrorr r r r r � s ��zResourceTracker._check_alivec C � | � d||� d S )N�REGISTER��_send�r �name�rtyper r r r � � zResourceTracker.registerc C r2 )N� UNREGISTERr4 r6 r r r r � r9 zResourceTracker.unregisterc C sB | � � d�|||��d�}t|�dkrtd��t�| j|�}d S )Nz{0}:{1}:{2} �asciii zmsg too long)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 ty1 Y q w dd� t �� D �}z�t| d��j}|D ]_}zF|�� �d��d�\}}}t �|d �}|d u rhtd|� d|� ���|dkrt|| �|� n|d kr�|| �|� n|d kr�ntd| ��W qD ty� z tjt�� � W n Y Y qDw W d � n1 s�w Y W |�� D ]I\}}|r�z t�dt|�|f � W n ty� Y nw |D ])}z&zt | |� W n ty� } zt�d || f � W Y d } ~ nd } ~ ww W q�w q�d S |�� D ]N\}}|�r'z t�dt|�|f � W n t�y& Y nw |D ]+}z(zt | |� W n t�yP } zt�d || f � W Y d } ~ nd } ~ ww W �q)w �qw )Nc S s i | ]}|t � �qS r )�set)�.0r8 r r r � <dictcomp>� s zmain.<locals>.<dictcomp>�rbr; �:zCannot 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'