Format: application/x-python-code
⬇ Download File (5.2 KB)
   1  o
   2  
   3  ;'h��@s�ddlmZddlmZmZmZddlmZddlm	Z	m
   4  Z
   5  mZddlm
   6  Z
   7  mZmZmZmZmZmZmZed�Zed�Zed	d
   8  �Gdd�de��Zed	d
   9  �Gd
  10  d�de
  11  eee��Zed	d
  12  �Gdd�de
  13  eee��ZdS)�)�annotations)�Callable�Mapping�Sequence)�	dataclass)�Any�Generic�TypeVar�)�ByteReceiveStream�ByteSendStream�
  14  ByteStream�Listener�ObjectReceiveStream�ObjectSendStream�ObjectStream�	TaskGroup�T_Item�T_StreamF)�eqc@sZeZdZUdZded<ded<dddd�Zddd�Zddd�Zddd�Ze	ddd��Z
  15  dS)�StapledByteStreamaV
  16      Combines two byte streams into a single, bidirectional byte stream.
  17  
  18      Extra attributes will be provided from both streams, with the receive stream
  19      providing the values in case of a conflict.
  20  
  21      :param ByteSendStream send_stream: the sending byte stream
  22      :param ByteReceiveStream receive_stream: the receiving byte stream
  23      r�send_streamr�receive_stream��	max_bytes�int�return�bytesc�s�|j�|�IdHS�N�r�receive)�selfr�r"�KC:\Users\shubh\Videos\agent\nova\Lib\site-packages\anyio/streams/stapled.pyr %s�zStapledByteStream.receive�item�Nonec���|j�|�IdHdSr�r�send�r!r$r"r"r#r((��zStapledByteStream.sendc���|j��IdHdSr�r�aclose�r!r"r"r#�send_eof+��zStapledByteStream.send_eofc��&�|j��IdH|j��IdHdSr�rr-rr.r"r"r#r-.��zStapledByteStream.aclose�Mapping[Any, Callable[[], Any]]cC�i|jj�|jj�Sr�r�extra_attributesrr.r"r"r#r72�
  24  ��z"StapledByteStream.extra_attributesN)r)rrrr)r$rrr%�rr%�rr4��__name__�
  25  __module__�__qualname__�__doc__�__annotations__r r(r/r-�propertyr7r"r"r"r#rs
  26  
  27  
  28  
  29  
  30  rc@sXeZdZUdZded<ded<ddd	�Zddd
  31  �Zddd�Zddd�Ze	ddd��Z
  32  dS)�StapledObjectStreamab
  33      Combines two object streams into a single, bidirectional object stream.
  34  
  35      Extra attributes will be provided from both streams, with the receive stream
  36      providing the values in case of a conflict.
  37  
  38      :param ObjectSendStream send_stream: the sending object stream
  39      :param ObjectReceiveStream receive_stream: the receiving object stream
  40      zObjectSendStream[T_Item]rzObjectReceiveStream[T_Item]rrrc�s�|j��IdHSrrr.r"r"r#r Is�zStapledObjectStream.receiver$r%c�r&rr'r)r"r"r#r(Lr*zStapledObjectStream.sendc�r+rr,r.r"r"r#r/Or0zStapledObjectStream.send_eofc�r1rr2r.r"r"r#r-Rr3zStapledObjectStream.acloser4cCr5rr6r.r"r"r#r7Vr8z$StapledObjectStream.extra_attributesN)rr)r$rrr%r9r:r;r"r"r"r#rB:s
  41  
  42  
  43  
  44  
  45  
  46  rBc@sJeZdZUdZded<ddd�Z	ddd
  47  d�Zddd�Zeddd��Z	dS)�
  48  MultiListenera�
  49      Combines multiple listeners into one, serving connections from all of them at once.
  50  
  51      Any MultiListeners in the given collection of listeners will have their listeners
  52      moved into this one.
  53  
  54      Extra attributes are provided from each listener, with each successive listener
  55      overriding any conflicting attributes from the previous one.
  56  
  57      :param listeners: listeners to serve
  58      :type listeners: Sequence[Listener[T_Stream]]
  59      zSequence[Listener[T_Stream]]�	listenersrr%cCsHg}|jD]}t|t�r|�|j�|jdd�=q|�|�q||_dSr)rD�
  60  isinstancerC�extend�append)r!rD�listenerr"r"r#�
  61  __post_init__os
  62  
  63  
  64  zMultiListener.__post_init__N�handler�Callable[[T_Stream], Any]�
  65  task_group�TaskGroup | Nonec	�sj�ddlm}|�4IdH�}|jD]
  66  }|�|j||�qWd�IdHdS1IdHs.wYdS)Nr
  67  )�create_task_group)�rNrDZ
  68  start_soon�serve)r!rJrLrN�tgrHr"r"r#rPzs�
  69  �.�zMultiListener.servec�s �|jD]	}|��IdHqdSr)rDr-)r!rHr"r"r#r-�s�
  70  �zMultiListener.acloser4cCs i}|jD]}|�|j�q|Sr)rD�updater7)r!�
  71  attributesrHr"r"r#r7�s
  72  zMultiListener.extra_attributesr9r)rJrKrLrMrr%r:)
  73  r<r=r>r?r@rIrPr-rAr7r"r"r"r#rC^s
  74  
  75  �
  76  	rCN)�
  77  __future__r�collections.abcrrr�dataclassesr�typingrrr	�abcrrr
  78  rrrrrrrrrBrCr"r"r"r#�<module>s(##