
    Rh)                         d Z dZ G d d      Z G d de      Z G d de      Z G d d	ee      Z G d
 de      Z G d de      Z G d de      Zy)zAbstract Transport class.)BaseTransportReadTransportWriteTransport	TransportDatagramTransportSubprocessTransportc                   <    e Zd ZdZdZd
dZd
dZd Zd Zd Z	d	 Z
y)r   zBase class for transports._extraNc                     |i }|| _         y Nr	   )selfextras     )/usr/lib/python3.12/asyncio/transports.py__init__zBaseTransport.__init__   s    =E    c                 :    | j                   j                  ||      S )z#Get optional transport information.)r
   get)r   namedefaults      r   get_extra_infozBaseTransport.get_extra_info   s    {{tW--r   c                     t         )z2Return True if the transport is closing or closed.NotImplementedErrorr   s    r   
is_closingzBaseTransport.is_closing       !!r   c                     t         )a  Close the transport.

        Buffered data will be flushed asynchronously.  No more data
        will be received.  After all buffered data is flushed, the
        protocol's connection_lost() method will (eventually) be
        called with None as its argument.
        r   r   s    r   closezBaseTransport.close   
     "!r   c                     t         )zSet a new protocol.r   )r   protocols     r   set_protocolzBaseTransport.set_protocol%   r   r   c                     t         )zReturn the current protocol.r   r   s    r   get_protocolzBaseTransport.get_protocol)   r   r   r   )__name__
__module____qualname____doc__	__slots__r   r   r   r   r"   r$    r   r   r   r   	   s(    $I
.""""r   r   c                   &    e Zd ZdZdZd Zd Zd Zy)r   z#Interface for read-only transports.r*   c                     t         )z*Return True if the transport is receiving.r   r   s    r   
is_readingzReadTransport.is_reading3   r   r   c                     t         )zPause the receiving end.

        No data will be passed to the protocol's data_received()
        method until resume_reading() is called.
        r   r   s    r   pause_readingzReadTransport.pause_reading7   
     "!r   c                     t         )zResume the receiving end.

        Data received will once again be passed to the protocol's
        data_received() method.
        r   r   s    r   resume_readingzReadTransport.resume_reading?   r0   r   N)r%   r&   r'   r(   r)   r-   r/   r2   r*   r   r   r   r   .   s    -I"""r   r   c                   F    e Zd ZdZdZddZd Zd Zd Zd Z	d	 Z
d
 Zd Zy)r   z$Interface for write-only transports.r*   Nc                     t         )a  Set the high- and low-water limits for write flow control.

        These two values control when to call the protocol's
        pause_writing() and resume_writing() methods.  If specified,
        the low-water limit must be less than or equal to the
        high-water limit.  Neither value can be negative.

        The defaults are implementation-specific.  If only the
        high-water limit is given, the low-water limit defaults to an
        implementation-specific value less than or equal to the
        high-water limit.  Setting high to zero forces low to zero as
        well, and causes pause_writing() to be called whenever the
        buffer becomes non-empty.  Setting low to zero causes
        resume_writing() to be called only once the buffer is empty.
        Use of zero for either limit is generally sub-optimal as it
        reduces opportunities for doing I/O and computation
        concurrently.
        r   r   highlows      r   set_write_buffer_limitsz&WriteTransport.set_write_buffer_limitsM   s
    & "!r   c                     t         )z,Return the current size of the write buffer.r   r   s    r   get_write_buffer_sizez$WriteTransport.get_write_buffer_sizeb   r   r   c                     t         )zGet the high and low watermarks for write flow control.
        Return a tuple (low, high) where low and high are
        positive number of bytes.r   r   s    r   get_write_buffer_limitsz&WriteTransport.get_write_buffer_limitsf   s
     "!r   c                     t         )zWrite some data bytes to the transport.

        This does not block; it buffers the data and arranges for it
        to be sent out asynchronously.
        r   )r   datas     r   writezWriteTransport.writel   r0   r   c                 H    dj                  |      }| j                  |       y)zWrite a list (or any iterable) of data bytes to the transport.

        The default implementation concatenates the arguments and
        calls write() on the result.
        r   N)joinr?   )r   list_of_datar>   s      r   
writelineszWriteTransport.writelinest   s     xx%

4r   c                     t         )zClose the write end after flushing buffered data.

        (This is like typing ^D into a UNIX program reading from stdin.)

        Data may still be received.
        r   r   s    r   	write_eofzWriteTransport.write_eof}   
     "!r   c                     t         )zAReturn True if this transport supports write_eof(), False if not.r   r   s    r   can_write_eofzWriteTransport.can_write_eof   r   r   c                     t         zClose the transport immediately.

        Buffered data will be lost.  No more data will be received.
        The protocol's connection_lost() method will (eventually) be
        called with None as its argument.
        r   r   s    r   abortzWriteTransport.abort   rF   r   NN)r%   r&   r'   r(   r)   r8   r:   r<   r?   rC   rE   rH   rK   r*   r   r   r   r   H   s2    .I"*""""""r   r   c                       e Zd ZdZdZy)r   aS  Interface representing a bidirectional transport.

    There may be several implementations, but typically, the user does
    not implement new transports; rather, the platform provides some
    useful transports that are implemented using the platform's best
    practices.

    The user never instantiates a transport directly; they call a
    utility function, passing it a protocol factory and other
    information necessary to create the transport and protocol.  (E.g.
    EventLoop.create_connection() or EventLoop.create_server().)

    The utility function will asynchronously create a transport and a
    protocol and hook them up by calling the protocol's
    connection_made() method, passing it the transport.

    The implementation here raises NotImplemented for every method
    except writelines(), which calls write() in a loop.
    r*   N)r%   r&   r'   r(   r)   r*   r   r   r   r      s    ( Ir   r   c                   "    e Zd ZdZdZddZd Zy)r   z(Interface for datagram (UDP) transports.r*   Nc                     t         )a  Send data to the transport.

        This does not block; it buffers the data and arranges for it
        to be sent out asynchronously.
        addr is target socket address.
        If addr is None use target address pointed on transport creation.
        r   )r   r>   addrs      r   sendtozDatagramTransport.sendto   r   r   c                     t         rJ   r   r   s    r   rK   zDatagramTransport.abort   rF   r   r   )r%   r&   r'   r(   r)   rQ   rK   r*   r   r   r   r      s    2I""r   r   c                   4    e Zd ZdZd Zd Zd Zd Zd Zd Z	y)	r   r*   c                     t         )zGet subprocess id.r   r   s    r   get_pidzSubprocessTransport.get_pid   r   r   c                     t         )zGet subprocess returncode.

        See also
        http://docs.python.org/3/library/subprocess#subprocess.Popen.returncode
        r   r   s    r   get_returncodez"SubprocessTransport.get_returncode   r0   r   c                     t         )z&Get transport for pipe with number fd.r   )r   fds     r   get_pipe_transportz&SubprocessTransport.get_pipe_transport   r   r   c                     t         )zSend signal to subprocess.

        See also:
        docs.python.org/3/library/subprocess#subprocess.Popen.send_signal
        r   )r   signals     r   send_signalzSubprocessTransport.send_signal   r0   r   c                     t         )aL  Stop the subprocess.

        Alias for close() method.

        On Posix OSs the method sends SIGTERM to the subprocess.
        On Windows the Win32 API function TerminateProcess()
         is called to stop the subprocess.

        See also:
        http://docs.python.org/3/library/subprocess#subprocess.Popen.terminate
        r   r   s    r   	terminatezSubprocessTransport.terminate   s
     "!r   c                     t         )zKill the subprocess.

        On Posix OSs the function sends SIGKILL to the subprocess.
        On Windows kill() is an alias for terminate().

        See also:
        http://docs.python.org/3/library/subprocess#subprocess.Popen.kill
        r   r   s    r   killzSubprocessTransport.kill   s
     "!r   N)
r%   r&   r'   r)   rU   rW   rZ   r]   r_   ra   r*   r   r   r   r      s%    I"""""	"r   r   c                   P     e Zd ZdZdZd
 fd	Zd Zd Zd Zd
dZ	d
dZ
d	 Z xZS )_FlowControlMixinav  All the logic for (write) flow control in a mix-in base class.

    The subclass must implement get_write_buffer_size().  It must call
    _maybe_pause_protocol() whenever the write buffer size increases,
    and _maybe_resume_protocol() whenever it decreases.  It may also
    override set_write_buffer_limits() (e.g. to specify different
    defaults).

    The subclass constructor must call super().__init__(extra).  This
    will call set_write_buffer_limits().

    The user may call set_write_buffer_limits() and
    get_write_buffer_size(), and their protocol's pause_writing() and
    resume_writing() may be called.
    )_loop_protocol_paused_high_water
_low_waterc                 h    t         |   |       |J || _        d| _        | j	                          y )NF)superr   rd   re   _set_write_buffer_limits)r   r   loop	__class__s      r   r   z_FlowControlMixin.__init__  s7    
 %%%'r   c                 @   | j                         }|| j                  k  ry | j                  s#d| _        	 | j                  j	                          y y # t
        t        f$ r  t        $ r4}| j                  j                  d|| | j                  d       Y d }~y d }~ww xY w)NTzprotocol.pause_writing() failedmessage	exception	transportr!   )
r:   rf   re   	_protocolpause_writing
SystemExitKeyboardInterruptBaseExceptionrd   call_exception_handler)r   sizeexcs      r   _maybe_pause_protocolz'_FlowControlMixin._maybe_pause_protocol  s    ))+4###$$$(D!
,,. %  12   

11@!$!% $	3  s   A B)*BBc                 <   | j                   rA| j                         | j                  k  r#d| _         	 | j                  j	                          y y y # t
        t        f$ r  t        $ r4}| j                  j                  d|| | j                  d       Y d }~y d }~ww xY w)NFz protocol.resume_writing() failedrn   )
re   r:   rg   rr   resume_writingrt   ru   rv   rd   rw   )r   ry   s     r   _maybe_resume_protocolz(_FlowControlMixin._maybe_resume_protocol'  s    !!**,?$)D!
--/ @ "
  12   

11A!$!% $	3  s   A B'*BBc                 2    | j                   | j                  fS r   )rg   rf   r   s    r   r<   z)_FlowControlMixin.get_write_buffer_limits7  s    !1!122r   c                     |
|d}nd|z  }||dz  }||cxk\  rdk\  sn t        d|d|d      || _        || _        y )Ni          zhigh (z) must be >= low (z) must be >= 0)
ValueErrorrf   rg   r5   s      r   rj   z*_FlowControlMixin._set_write_buffer_limits:  sh    <{ 3w;!)Csa 23'HJ J  r   c                 J    | j                  ||       | j                          y )N)r6   r7   )rj   rz   r5   s      r   r8   z)_FlowControlMixin.set_write_buffer_limitsJ  s!    %%4S%9""$r   c                     t         r   r   r   s    r   r:   z'_FlowControlMixin.get_write_buffer_sizeN  s    !!r   rL   )r%   r&   r'   r(   r)   r   rz   r}   r<   rj   r8   r:   __classcell__)rl   s   @r   rc   rc      s3      KI($ 3 %"r   rc   N)	r(   __all__r   r   r   r   r   r   rc   r*   r   r   <module>r      sj    "" ""J"M "4I"] I"X~ 0" "23"- 3"lT"	 T"r   