관리-도구
편집 파일: shared_memory.cpython-310.opt-2.pyc
o 6��fH � @ s� d dgZ ddlmZ ddlZddlZddlZddlZddlZddlZej dkr/ddl Z dZnddlZdZdd l mZ ejejB Zd ZerHdZndZd d� ZG dd � d �ZdZG dd� d�ZdS )�SharedMemory� ShareableList� )�partialN�ntFT� )�resource_tracker� z/psm_Zwnsm_c C s$ t tt� d } tt�| � }|S )N� )�_SHM_SAFE_NAME_LENGTH�len�_SHM_NAME_PREFIX�secretsZ token_hex)�nbytes�name� r �D/opt/alt/python310/lib64/python3.10/multiprocessing/shared_memory.py�_make_filename( s r c @ s� e Zd Z dZdZdZdZejZ dZ erdndZddd�Z d d � Zdd� Zd d� Zedd� �Zedd� �Zedd� �Zdd� Zdd� ZdS )r N���i� TFr c C sx |dkst d��|rttjB | _|dkrt d��|d u r&| jtj@ s&t d��tr�|d u rL t� }z tj || j| j d�| _W n tyF Y q,w || _ n| jrSd| n|}tj || j| j d�| _|| _ z|ro|rot�| j|� t�| j�}|j}t�| j|�| _W n ty� | �� � w t�| j d� n�|r� |d u r�t� n|}t�tjtjtj|d ? d @ |d @ |�}z1t�� }|tjkr�|d ur�ttj t�!tj �|tj��W t�"|� q�tjd||d�| _W t�"|� nt�"|� w || _ n?|| _ t�#tj$d |�}zt�%|tj$ddd�}W t�"|� nt�"|� w zt�&|�}W t�'|� nt�'|� w tjd||d�| _|| _(t)| j�| _*d S )Nr z!'size' must be a positive integerz4'size' must be a positive number different from zeroz&'name' can only be None if create=TrueT)�mode�/� shared_memory� l �� r )ZtagnameF)+� ValueError�_O_CREX�os�O_RDWR�_flags�O_EXCL� _USE_POSIXr �_posixshmemZshm_open�_mode�_fd�FileExistsError�_name�_prepend_leading_slash� ftruncate�fstat�st_size�mmap�_mmap�OSError�unlinkr �register�_winapiZCreateFileMappingZINVALID_HANDLE_VALUEZNULLZPAGE_READWRITEZGetLastErrorZERROR_ALREADY_EXISTS�errnoZEEXIST�strerrorZCloseHandleZOpenFileMappingZ FILE_MAP_READZ MapViewOfFileZVirtualQuerySizeZUnmapViewOfFile�_size� memoryview�_buf) �selfr �create�sizeZstatsZ temp_nameZh_mapZlast_error_codeZp_bufr r r �__init__K s� ���� � ����zSharedMemory.__init__c C s$ z| � � W d S ty Y d S w �N)�closer* �r3 r r r �__del__� s �zSharedMemory.__del__c C s | j | jd| jffS )NF)� __class__r r5 r9 r r r � __reduce__� s ��zSharedMemory.__reduce__c C s | j j� d| j�d| j� d�S )N�(z, size=�))r; �__name__r r5 r9 r r r �__repr__� s zSharedMemory.__repr__c C � | j S r7 )r2 r9 r r r �buf� � zSharedMemory.bufc C s0 | j }tr| jr| j �d�r| j dd � }|S )Nr r )r# r r$ � startswith)r3 Z reported_namer r r r � s zSharedMemory.namec C rA r7 )r0 r9 r r r r5 � rC zSharedMemory.sizec C sb | j d ur| j �� d | _ | jd ur| j�� d | _tr-| jdkr/t�| j� d| _d S d S d S )Nr r )r2 �releaser) r8 r r! r r9 r r r r8 � s �zSharedMemory.closec C s2 t r| jrt�| j� t�| jd� d S d S d S )Nr )r r# r Z shm_unlinkr � unregisterr9 r r r r+ � s �zSharedMemory.unlink)NFr )r? � __module__�__qualname__r# r! r) r2 r r r r r r$ r6 r: r<