ok
Direktori : /opt/alt/python38/lib64/python3.8/multiprocessing/__pycache__/ |
Current File : //opt/alt/python38/lib64/python3.8/multiprocessing/__pycache__/resource_tracker.cpython-38.pyc |
U .��c�! � @ s� d dl Z d dlZd dlZd dlZd dlZddlmZ ddlmZ dddgZe ed�Z ejejfZ d d d� iZe jdkr�d dlZd dlZe�ejejd �� G dd� de�Ze� ZejZejZejZejZdd� ZdS )� N� )�spawn)�util�ensure_running�register� unregister�pthread_sigmaskZnoopc C s d S �N� r r r �E/opt/alt/python38/lib64/python3.8/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 sT | j �D | jd kr W 5 Q R � d S t�| j� d | _t�| jd� d | _W 5 Q R X 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 st | j ��b | jdk r~| �� r*W 5 Q R � dS t�| j� z| jdk rPt�| jd� W n tk rf Y nX d| _d| _t� d� g }z|� tj� � � W n tk r� Y nX d}t�� \}}z�zr|� |� t�� }|gt�� }|d|| g7 }z&t�rt�tjt� t�|||�}W 5 t�r,t�tjt� X W n t�|� � Y nX || _|| _W 5 t�|� X W 5 Q R X 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_UNBLOCK�_IGNORED_SIGNALS� SIG_BLOCKZspawnv_passfds)r Zfds_to_pass�cmd�r�wZexe�args�pidr r r r F sJ zResourceTracker.ensure_runningc C s2 zt �| jd� W n tk r( Y dS X 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^td�|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 �AssertionError)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> tk rb Y q>X q>dd� t �� D �}z�t| d���}|D ]�}z�|�� �d��d�\}}}t �|d�} | dkr�td |� d |� ���|dkr�|| �|� n2|dk�r|| �|� n|d k�rntd| ��W q� tk �rT ztjt�� � W n Y nX Y q�X q�W 5 Q R X W 5 |�� D ]�\}}|�r�zt�dt|�|f � W n tk �r� Y nX |D ]V}zLzt | |� W n6 tk �r� } zt�d||f � W 5 d}~X Y nX W 5 X �q��qnX dS )zRun resource tracker.c S s i | ]}|t � �qS r )�set)�.0r7 r r r � <dictcomp>� s zmain.<locals>.<dictcomp>zQresource_tracker: There appear to be %d leaked %s objects to clean up at shutdownzresource_tracker: %r: %sN�rbr9 �:zCannot register z. for automatic cleanup: unknown resource type r2 r8 ZPROBEzunrecognized command %r)r'