Viewing File: /opt/alt/python38/lib64/python3.8/site-packages/aiohttp/__pycache__/streams.cpython-38.opt-1.pyc

U

'7`2P@s8ddlZddlZddlZddlmZmZmZmZmZm	Z	m
Z
ddlmZddl
mZmZmZddlmZzddlmZWn ek
rddlmZYnXdZe
d	ZGd
ddeZGdd
d
eeZGdddZGdddZGdddeZGdddeZeZGdddeeZ Gddde eZ!dS)N)	AwaitableCallableGenericListOptionalTupleTypeVar)BaseProtocol)BaseTimerContext
set_exception
set_result)internal_logger)Deque)
EMPTY_PAYLOAD	EofStreamStreamReader	DataQueueFlowControlDataQueue_Tc@seZdZdZdS)rzeof stream indication.N)__name__
__module____qualname____doc__rrB/opt/alt/python38/lib64/python3.8/site-packages/aiohttp/streams.pyrsrc@sDeZdZegeefddddZddddZedd	d
ZdS)AsyncStreamIteratorN)	read_funcreturncCs
||_dSN)r)selfrrrr__init__szAsyncStreamIterator.__init__zAsyncStreamIterator[_T]rcCs|Srrr rrr	__aiter__"szAsyncStreamIterator.__aiter__cs<z|IdH}Wntk
r*tYnX|dkr8t|SN)rrStopAsyncIterationr rvrrr	__anext__%s
zAsyncStreamIterator.__anext__)	rrrrrrr!r$r*rrrrrsrc@s@eZdZdddddZddddZeeefdd	d
ZdS)ChunkTupleAsyncStreamIteratorrN)streamrcCs
||_dSr)_stream)r r,rrrr!0sz&ChunkTupleAsyncStreamIterator.__init__r"cCs|Srrr#rrrr$3sz'ChunkTupleAsyncStreamIterator.__aiter__cs |jIdH}|dkrt|S)Nr&F)r-	readchunkr'r(rrrr*6sz'ChunkTupleAsyncStreamIterator.__anext__)	rrrr!r$rbytesboolr*rrrrr+/sr+c@sReZdZeedddZeeedddZeedddZe	dd	d
Z
dS)AsyncStreamReaderMixinr"cCs
t|jSr)rreadliner#rrrr$>sz AsyncStreamReaderMixin.__aiter__nrcstfddS)zzReturns an asynchronous iterator that yields chunks of size n.

        Python-3.5 available for Python 3.5+ only
        cs
Sr)readrr5r rr<lambda>Fr&z5AsyncStreamReaderMixin.iter_chunked.<locals>.<lambda>)rr r5rr7riter_chunkedAsz#AsyncStreamReaderMixin.iter_chunkedcCs
t|jS)zReturns an asynchronous iterator that yields all the available
        data as soon as it is received

        Python-3.5 available for Python 3.5+ only
        )rreadanyr#rrriter_anyHszAsyncStreamReaderMixin.iter_anycCst|S)a
Returns an asynchronous iterator that yields chunks of data
        as they are received by the server. The yielded objects are tuples
        of (bytes, bool) as returned by the StreamReader.readchunk method.

        Python-3.5 available for Python 3.5+ only
        )r+r#rrriter_chunksPsz"AsyncStreamReaderMixin.iter_chunksN)rrrrr0r$intr:r<r+r=rrrrr2=sr2c@seZdZdZdZdddeeeeee	j
ddddZedd	d
Z
eeefdddZeedd
dZeddddZegdfddddZddddZedddZedddZddddZeddddZd<eedd d!d"Zddd#d$Zddd%d&Zedd'd(d)Zedd*d+Z d=eed-d.d/Z!edd0d1Z"eeefdd2d3Z#eed-d4d5Z$d>eed-d6d7Z%eed-d8d9Z&eed-d:d;Z'dS)?ra*An enhancement of asyncio.StreamReader.

    Supports asynchronous iteration by line, chunk or as available::

        async for line in reader:
            ...
        async for chunk in reader.iter_chunked(1024):
            ...
        async for slice in reader.iter_any():
            ...

    rN)timerloop)protocollimitr?r@rcCsv||_||_|d|_|dkr&t}||_d|_d|_d|_t	
|_d|_d|_
d|_d|_d|_||_g|_dS)NrF)	_protocol
_low_water_high_waterasyncioZget_event_loop_loop_size_cursor_http_chunk_splitscollectionsdeque_buffer_buffer_offset_eof_waiter_eof_waiter
_exception_timer_eof_callbacks)r rArBr?r@rrrr!js"

zStreamReader.__init__r"cCs|jjg}|jr |d|j|jr0|d|jdkrP|d|j|jf|jrf|d|j|jr||d|jdd	|S)	Nz%d byteseofizlow=%d high=%dzw=%rze=%rz<%s> )
	__class__rrIappendrPrErFrQrSjoin)r inforrr__repr__s


zStreamReader.__repr__cCs|j|jfSr)rErFr#rrrget_read_buffer_limitssz#StreamReader.get_read_buffer_limitscCs|jSrrSr#rrr	exceptionszStreamReader.exceptionexcrcCsP||_|j|j}|dk	r.d|_t|||j}|dk	rLd|_t||dSr)rSrUclearrQrrRr rawaiterrrrrs

zStreamReader.set_exceptioncallbackrcCsB|jr2z
|Wq>tk
r.tdYq>Xn|j|dSNException in eof callback)rP	Exceptionrr_rUrYr rfrrron_eofs
zStreamReader.on_eofc	Csd|_|j}|dk	r$d|_t|d|j}|dk	rBd|_t|d|jD].}z
|WqHtk
rttdYqHXqH|jdS)NTrh)	rPrQr
rRrUrirr_rb)r rdcbrrrfeed_eofs



zStreamReader.feed_eofcCs|jS)z&Return True if  'feed_eof' was called.rPr#rrris_eofszStreamReader.is_eofcCs|jo|jS)z=Return True if the buffer is empty and 'feed_eof' was called.rPrNr#rrrat_eofszStreamReader.at_eofcs4|jr
dS|j|_z|jIdHW5d|_XdSr)rPrH
create_futurerRr#rrrwait_eofszStreamReader.wait_eof)datarcCsxtjdtdd|sdS|jr>|jd|jd|jd<d|_|jt|7_|jt|8_|j|d|_	dS)zDrollback reading some data from stream, inserting it to buffer head.zJunread_data() is deprecated and will be removed in future releases (#3260)rC)
stacklevelNr)
warningswarnDeprecationWarningrOrNrIlenrJ
appendleftZ_eof_counter)r rtrrrunread_dataszStreamReader.unread_datartsizercCsx|sdS|jt|7_|j||jt|7_|j}|dk	rVd|_t|d|j|jkrt|jj	st|j
dSr)rIryrNrYtotal_bytesrQr
rFrD_reading_paused
pause_readingr rtr}rdrrr	feed_datas
zStreamReader.feed_datacCs"|jdkr|jrtdg|_dS)Nz?Called begin_http_chunk_receiving whensome data was already fed)rKr~RuntimeErrorr#rrrbegin_http_chunk_receivings
z'StreamReader.begin_http_chunk_receivingcCsd|jdkrtd|jr"|jdnd}|j|kr4dS|j|j|j}|dk	r`d|_t|ddS)NzFCalled end_chunk_receiving without calling begin_chunk_receiving firstr)rKrr~rYrQr
)r posrdrrrend_http_chunk_receivings


z%StreamReader.end_http_chunk_receiving)	func_namerc	sf|jdk	rtd||j}|_z2|jrL|j|IdHW5QRXn
|IdHW5d|_XdS)NzH%s() called while another coroutine is already waiting for incoming data)rQrrHrrrT)r rrdrrr_wait#s
zStreamReader._waitcs|jdk	r|jg}d}d}|r|jr|r|j}|jdd|d}||rV||nd}|||t|7}|rzd}||jkr tdq |j	rq|r|
dIdHqd	|S)
NrT
r	rFzLine is too longr3r&)rSrNrOfind_read_nowait_chunkrYryrF
ValueErrorrPrrZ)r lineZ	line_sizeZ
not_enoughoffsetZicharrtrrrr38s*




zStreamReader.readlinerr4csv|jdk	r|j|sdS|dkrNg}|IdH}|s8qD||q$d|S|jsl|jsl|dIdHqN|	|S)Nr&rr6)
rSgetattrrr;rYrZrNrPr_read_nowait)r r5blocksblockrrrr6Vs

zStreamReader.readcs8|jdk	r|j|js.|js.|dIdHq|dS)Nr;r)rSrNrPrrr#rrrr;s

zStreamReader.readanycs|jdk	r|j|jrZ|jd}||jkr0dS||jkrN|||jdfStdq|jrn|ddfS|j	rxdS|
d	IdHqdS)
zReturns a tuple of (data, end_of_http_chunk). When chunked transfer
        encoding is used, end_of_http_chunk is a boolean indicating if the end
        of the data corresponds to the end of a HTTP chunk , otherwise it is
        always False.
        Nrr&TTzESkipping HTTP chunk end due to data consumption beyond chunk boundaryrFr.r/)rSrKpoprJrrZwarningrNrrPr)r rrrrr/s 


zStreamReader.readchunkcsp|jdk	r|jg}|dkrf||IdH}|sNd|}t|t|||||t|8}qd|S)Nrr&)rSr6rZrGIncompleteReadErrorryrY)r r5rrpartialrrrreadexactlys


zStreamReader.readexactlycCs2|jdk	r|j|jr(|js(td||S)Nz9Called while some coroutine is waiting for incoming data.)rSrQZdonerrr9rrrread_nowaits
zStreamReader.read_nowaitcCs|jd}|j}|dkrHt|||krH||||}|j|7_n,|rj|j||d}d|_n
|j}|jt|8_|jt|7_|j}|r|d|jkr|dq|j|jkr|j	j
r|j	|S)Nrr)rNrOrypopleftrIrJrKrrErDrresume_reading)r r5Zfirst_bufferrrtZchunk_splitsrrrrs$



zStreamReader._read_nowait_chunkcCsPg}|jr>||}|||dkr|t|8}|dkrq>q|rLd|SdS)z8 Read not more than n bytes, or whole buffer if n == -1 rrr&)rNrrYryrZ)r r5Zchunkschunkrrrrs

zStreamReader._read_nowait)r)r)r)(rrrrr~r
r>rrrGAbstractEventLoopr!strr\rr]
BaseExceptionr_rrrkrmr1rorqrsr0r{rrrrr3r6r;r/rrrrrrrrrZsB
	* rc@seZdZeedddZeddddZegdfddd	d
ZddddZ	e
dd
dZe
dddZddddZ
d%eeddddZedddZd&eedddZedddZeee
fddd Zeedd!d"Zedd#d$ZdS)'EmptyStreamReaderr"cCsdSrrr#rrrr_szEmptyStreamReader.exceptionNr`cCsdSrr)r rarrrrszEmptyStreamReader.set_exceptionrecCs.z
|Wntk
r(tdYnXdSrg)rirr_rjrrrrks
zEmptyStreamReader.on_eofcCsdSrrr#rrrrmszEmptyStreamReader.feed_eofcCsdSNTrr#rrrroszEmptyStreamReader.is_eofcCsdSrrr#rrrrqszEmptyStreamReader.at_eofcsdSrrr#rrrrs
szEmptyStreamReader.wait_eofr)rtr5rcCsdSrr)r rtr5rrrr
szEmptyStreamReader.feed_datacsdSr%rr#rrrr3szEmptyStreamReader.readlinerr4csdSr%rr9rrrr6szEmptyStreamReader.readcsdSr%rr#rrrr;szEmptyStreamReader.readanycsdS)Nrrr#rrrr/szEmptyStreamReader.readchunkcstd|dSr%)rGrr9rrrrszEmptyStreamReader.readexactlycCsdSr%rr#rrrrszEmptyStreamReader.read_nowait)r)r)rrrrrr_rrrkrmr1rorqrsr0r>rr3r6r;rr/rrrrrrrsrc@seZdZdZejddddZedddZe	dd	d
Z
e	dddZee
dd
dZe
ddddZdeeddddZddddZedddZeedddZdS)rz>DataQueue is a general-purpose blocking queue with one reader.N)r@rcCs,||_d|_d|_d|_d|_t|_dS)NFr)rHrPrQrSrIrLrMrN)r r@rrrr!)szDataQueue.__init__r"cCs
t|jSr)ryrNr#rrr__len__1szDataQueue.__len__cCs|jSrrnr#rrrro4szDataQueue.is_eofcCs|jo|jSrrpr#rrrrq7szDataQueue.at_eofcCs|jSrr^r#rrrr_:szDataQueue.exceptionr`cCs.d|_||_|j}|dk	r*d|_t||dSr)rPrSrQrrcrrrr=szDataQueue.set_exceptionrr|cCs@|j|7_|j||f|j}|dk	r<d|_t|ddSr)rIrNrYrQr
rrrrrFszDataQueue.feed_datacCs(d|_|j}|dk	r$d|_t|ddSr)rPrQr
)r rdrrrrmOs
zDataQueue.feed_eofc	s|jsN|jsN|j|_z|jIdHWn$tjtjfk
rLd|_YnX|jrt|j\}}|j	|8_	|S|j
dk	r|j
ntdSr)rNrPrHrrrQrGZCancelledErrorTimeoutErrorrrIrSrr rtr}rrrr6Ws
zDataQueue.readcCs
t|jSr)rr6r#rrrr$kszDataQueue.__aiter__)r)rrrrrGrr!r>rr1rorqrrr_rrrrmr6rr$rrrrr&s		rcsXeZdZdZeeejddfddZd
e	eddfdd	
Z
e	d
fddZZS)rzgFlowControlDataQueue resumes and pauses an underlying stream.

    It is a destination for parsed data.N)rArBr@rcs"tj|d||_|d|_dS)N)r@rC)superr!rD_limit)r rArBr@rXrrr!tszFlowControlDataQueue.__init__rr|cs0t|||j|jkr,|jjs,|jdSr)rrrIrrDrrrrrrr|szFlowControlDataQueue.feed_datar"cs:ztIdHWS|j|jkr4|jjr4|jXdSr)rIrrDrrrr6r#rrrr6szFlowControlDataQueue.read)r)
rrrrr
r>rGrr!rrr6
__classcell__rrrrrosr)"rGrLrvtypingrrrrrrrZ
base_protocolr
Zhelpersrrr
logrrImportErrorZtyping_extensions__all__rrirrr+r2rrrrrrrrr<module>s0$/I
Back to Directory File Manager