Mini Shell
a
�DOg h � @ s& d Z ddlZddlZddlZddlZeed�r6e d7 Z ddlmZ ddlmZ ddlm Z dd lm
Z
dd
lmZ ddlm
Z
ddlmZ d
Zdded�dd�Zd ded�dd�Zeed�r�d!ded�dd�Zd"ded�dd�ZG dd� dej�ZG dd� deej�ZG dd� d�ZG dd� d�ZdS )#)�StreamReader�StreamWriter�StreamReaderProtocol�open_connection�start_server� N�AF_UNIX)�open_unix_connection�start_unix_server� )�
coroutines)�events)�
exceptions)�format_helpers)� protocols)�logger)�sleepi )�loop�limitc � sx |du rt �� }ntjdtdd� t||d�}t||d�� |j� fdd�| |fi |��I dH \}}t|� ||�}||fS ) a� A wrapper for create_connection() returning a (reader, writer) pair.
The reader returned is a StreamReader instance; the writer is a
StreamWriter instance.
The arguments are all the usual arguments to create_connection()
except protocol_factory; most common are positional host and port,
with various optional keyword arguments following.
Additional optional keyword arguments are loop (to set the event loop
instance to use) and limit (to set the buffer limit passed to the
StreamReader).
(If you want to customize the StreamReader and/or
StreamReaderProtocol classes, just copy the code -- there's
really nothing special here except some convenience.)
N�[The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.� ��
stacklevel�r r �r c s � S �N� r ��protocolr �'/usr/lib64/python3.9/asyncio/streams.py�<lambda>5 � z!open_connection.<locals>.<lambda>) r �get_event_loop�warnings�warn�DeprecationWarningr r �create_connectionr ) �host�portr r �kwds�reader� transport�_�writerr r r r s
���r c � sN �du rt �� �ntjdtdd� � ��fdd�}�j|||fi |��I dH S )a� Start a socket server, call back for each client connected.
The first parameter, `client_connected_cb`, takes two parameters:
client_reader, client_writer. client_reader is a StreamReader
object, while client_writer is a StreamWriter object. This
parameter can either be a plain callback function or a coroutine;
if it is a coroutine, it will be automatically converted into a
Task.
The rest of the arguments are all the usual arguments to
loop.create_server() except protocol_factory; most common are
positional host and port, with various optional keyword arguments
following. The return value is the same as loop.create_server().
Additional optional keyword arguments are loop (to set the event loop
instance to use) and limit (to set the buffer limit passed to the
StreamReader).
The return value is the same as loop.create_server(), i.e. a
Server object which can be used to stop the service.
Nr r r c s t ��d�} t| � �d�}|S �Nr r �r r �r) r ��client_connected_cbr r r r �factoryX s
�zstart_server.<locals>.factory)r r! r"