File: //lib64/python3.9/multiprocessing/__pycache__/connection.cpython-39.pyc
a
    ���hp|  �                   @   s  g d �Z ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZ ddl
mZm
Z
 ddlmZ ejZz$ddlZddlmZmZmZmZ W n" ey�   ejdkr�� dZY n0 d	Zd
ZdZe�� ZdZdgZe ed
�r�d
Zed
g7 Zejdk�rdZedg7 Zefdd�Z!dd� Z"dd� Z#dd� Z$dd� Z%G dd� d�Z&e�rfG dd� de&�Z'G dd� de&�Z(G dd � d e)�Z*dQd!d"�Z+ejdk�r�dRd$d%�Z,n
dSd&d%�Z,G d'd(� d(e)�Z-d)d*� Z.ejdk�r�G d+d,� d,e)�Z/d-d.� Z0d/Z1d0Z2d1Z3d2Z4d3d4� Z5d5d6� Z6G d7d8� d8e)�Z7d9d:� Z8d;d<� Z9G d=d>� d>e*�Z:d?d@� Z;ejdk�rrdAdB� Z<ej=ej>hZ?dTdCdD�Z@n,ddlAZAe eAdE��r�eAjBZCneAjDZCdUdFdD�Z@ejdk�r�dGdH� ZEdIdJ� ZFe�Ge(eE� dKdL� ZHdMdN� ZIe�Ge'eH� ndOdH� ZEdPdJ� ZFe�Ge(eE� dS )V)�Client�Listener�Pipe�wait�    N�   )�util)�AuthenticationError�BufferTooShort)�	reduction)�
WAIT_OBJECT_0�WAIT_ABANDONED_0�WAIT_TIMEOUT�INFINITE�win32i    g      4@�sha256�AF_INET�AF_UNIX�AF_PIPEc                 C   s   t �� |  S �N��time�	monotonic)�timeout� r   �2/usr/lib64/python3.9/multiprocessing/connection.py�
_init_timeout?   s    r   c                 C   s   t �� | kS r   r   )�tr   r   r   �_check_timeoutB   s    r   c                 C   sX   | dkrdS | dkr&t jdt�� d�S | dkrLt jdt�� tt�f dd�S td	��d
S )z?
    Return an arbitrary free address for the given family
    r   )�	localhostr   r   z	listener-)�prefix�dirr   z\\.\pipe\pyc-%d-%d-� zunrecognized familyN)	�tempfile�mktempr   �get_temp_dir�os�getpid�next�
_mmap_counter�
ValueError��familyr   r   r   �arbitrary_addressI   s    ��r,   c                 C   sJ   t jdkr| dkrtd|  ��t jdkrF| dkrFtt| �sFtd|  ��dS )zD
    Checks if the family is valid for the current environment.
    r   r   zFamily %s is not recognized.r   N)�sys�platformr)   �hasattr�socketr*   r   r   r   �_validate_familyW   s
    
r1   c                 C   sT   t | �tkrdS t | �tu r*| �d�r*dS t | �tu s@t�| �rDdS td|  ��dS )z]
    Return the types of the address
    This can be 'AF_INET', 'AF_UNIX', or 'AF_PIPE'
    r   z\\r   r   zaddress type of %r unrecognizedN)�type�tuple�str�
startswithr   �is_abstract_socket_namespacer)   )�addressr   r   r   �address_typec   s    r8   c                   @   s�   e Zd ZdZd+dd�Zdd� Zdd� Zd	d
� Zdd� Zd
d� Z	e
dd� �Ze
dd� �Ze
dd� �Z
dd� Zdd� Zd,dd�Zdd� Zd-dd�Zd.d d!�Zd"d#� Zd/d%d&�Zd'd(� Zd)d*� ZdS )0�_ConnectionBaseNTc                 C   s>