a c@sddlmZddlmZmZmZmZmZmZm Z m Z ddl m Z m Z mZmZmZmZmZmZe dZe dZeddGd d d eZeddGd d d eeeeZeddGd ddeeeeZdS)) dataclass)AnyCallableGenericListMappingOptionalSequenceTypeVar)ByteReceiveStreamByteSendStream ByteStreamListenerObjectReceiveStreamObjectSendStream ObjectStream TaskGroupT_ItemT_StreamF)eqc@seZdZUdZeed<eed<deedddZ edd d d Z dd d dZ dd ddZ e eeegeffd ddZdS)StapledByteStreamaV Combines two byte streams into a single, bidirectional byte stream. Extra attributes will be provided from both streams, with the receive stream providing the values in case of a conflict. :param ByteSendStream send_stream: the sending byte stream :param ByteReceiveStream receive_stream: the receiving byte stream send_streamreceive_stream) max_bytesreturncs|j|IdHSNrreceive)selfrr!b/workspaces/shunt/resources/test-fastapi/venv/lib/python3.9/site-packages/anyio/streams/stapled.pyr"szStapledByteStream.receiveNitemrcs|j|IdHdSrrsendr r$r!r!r"r&%szStapledByteStream.sendrcs|jIdHdSrracloser r!r!r"send_eof(szStapledByteStream.send_eofcs$|jIdH|jIdHdSrrr*rr+r!r!r"r*+szStapledByteStream.aclosecCsi|jj|jjSrrextra_attributesrr+r!r!r"r//s z"StapledByteStream.extra_attributes)r)__name__ __module__ __qualname____doc__r __annotations__r intbytesrr&r,r*propertyrrrr/r!r!r!r"rs  rc@seZdZUdZeeed<eeed<edddZeddd d Z ddd d Z ddd dZ e e eegeffdddZdS)StapledObjectStreamab Combines two object streams into a single, bidirectional object stream. Extra attributes will be provided from both streams, with the receive stream providing the values in case of a conflict. :param ObjectSendStream send_stream: the sending object stream :param ObjectReceiveStream receive_stream: the receiving object stream rrr(cs|jIdHSrrr+r!r!r"rFszStapledObjectStream.receiveNr#cs|j|IdHdSrr%r'r!r!r"r&IszStapledObjectStream.sendcs|jIdHdSrr)r+r!r!r"r,LszStapledObjectStream.send_eofcs$|jIdH|jIdHdSrr-r+r!r!r"r*OszStapledObjectStream.aclosecCsi|jj|jjSrr.r+r!r!r"r/Ss z$StapledObjectStream.extra_attributes)r0r1r2r3rrr4rrr&r,r*r7rrrr/r!r!r!r"r87s   r8c@seZdZUdZeeeed<ddddZde ege fe e dddd Z ddd d Zeee e ge ffdd d ZdS) MultiListenera Combines multiple listeners into one, serving connections from all of them at once. Any MultiListeners in the given collection of listeners will have their listeners moved into this one. Extra attributes are provided from each listener, with each successive listener overriding any conflicting attributes from the previous one. :param listeners: listeners to serve :type listeners: Sequence[Listener[T_Stream]] listenersNr(cCsHg}|jD]2}t|tr2||j|jdd=q ||q ||_dSr)r: isinstancer9extendappend)r r:listenerr!r!r" __post_init__ls    zMultiListener.__post_init__)handler task_grouprc sfddlm}|4IdH2}|jD]}||j||q"WdIdHqb1IdHsX0YdS)Nr )create_task_group)rBr:Z start_soonserve)r r@rArBtgr>r!r!r"rDws  zMultiListener.servecs|jD]}|IdHqdSr)r:r*)r r>r!r!r"r*s zMultiListener.aclosecCs i}|jD]}||jq |Sr)r:updater/)r attributesr>r!r!r"r/s zMultiListener.extra_attributes)N)r0r1r2r3r rrr4r?rrrrrDr*r7rr/r!r!r!r"r9[s    r9N)Z dataclassesrtypingrrrrrrr r abcr r rrrrrrrrrr8r9r!r!r!r"s (( ##