Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/__pycache__/portend.cpython-39.pyc
Ðазад
a s�hX � @ s� d Z ddlZddlZddlZddlZddlZddlZddlZddlm Z ddl Zddlm Z dd� ZG dd� de�ZG d d � d e�ZG dd� de�Zed �fdd�Zed �fdd�Zdd� ZG dd� de�Zddd�Zedko�e� dS )z: A simple library for managing the availability of ports. � N)�abc)�timingc C s | dkrdS | dv rdS | S )z� Return the host on which a client can connect to the given listener. >>> client_host('192.168.0.1') '192.168.0.1' >>> client_host('0.0.0.0') '127.0.0.1' >>> client_host('::') '::1' z0.0.0.0z 127.0.0.1)z::z::0z ::0.0.0.0z::1� )Zserver_hostr r �w/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/portend.py�client_host s r c @ s( e Zd Zd dd�Zd dd�Zdd� ZdS )�Checker� �?c C s || _ d S �N��timeout)�selfr r r r �__init__) s zChecker.__init__Nc C sb |du r$t |tj�r$|dd� \}}t�� dkr8t|�}t�||tjtj �}t t�| j |�� dS )a� Assert that the given addr is free in that all attempts to connect fail within the timeout or raise a PortNotFree exception. >>> free_port = find_available_local_port() >>> Checker().assert_free('localhost', free_port) >>> Checker().assert_free('127.0.0.1', free_port) >>> Checker().assert_free('::1', free_port) Also accepts an addr tuple >>> addr = '::1', free_port, 0, 0 >>> Checker().assert_free(addr) Host might refer to a server bind address like '::', which should use localhost to perform the check. >>> Checker().assert_free('::', free_port) N� �Windows)� isinstancer �Sequence�platform�systemr �socket�getaddrinfo� AF_UNSPEC�SOCK_STREAM�list� itertools�starmap�_connect)r �host�port�infor r r �assert_free, s zChecker.assert_freec C s� t � |||�}|�| j� t�|��B z|�|� W n" t jyV Y W d � d S 0 W d � n1 sl0 Y |d d� \}}d} t| jf i t � ����d S )Nr z Port {port} is in use on {host}.) r � settimeoutr � contextlib�closing�connect�error�PortNotFree�format�locals) r �af�socktype�proto� canonname�sa�sr r �tmplr r r r I s 2zChecker._connect)r )N)�__name__� __module__�__qualname__r r r r r r r r ( s r c @ s e Zd ZdS )�TimeoutN�r/ r0 r1 r r r r r2 Z s r2 c @ s e Zd ZdS )r% Nr3 r r r r r% ^ s r% ZInfc C sp | st d��t�|�}ztdd��| |� W dS tyh |�� rZtdjf i t � ����t �d� Y q0 qdS )u� Wait for the specified port to become free (dropping or rejecting requests). Return when the port is free or raise a Timeout if timeout has elapsed. Timeout may be specified in seconds or as a timedelta. If timeout is None or ∞, the routine will run indefinitely. >>> free('localhost', find_available_local_port()) >>> free(None, None) Traceback (most recent call last): ... ValueError: Host values of '' or None are not allowed. �*Host values of '' or None are not allowed.皙�����?r NzPort {port} not free on {host}.)� ValueErrorr �Timerr r r% �expiredr2 r&